]> git.proxmox.com Git - pve-installer.git/commitdiff
auto-installer: move `system.root_ssh_keys` option to `global` section
authorChristoph Heiss <c.heiss@proxmox.com>
Mon, 22 Apr 2024 17:47:37 +0000 (19:47 +0200)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Mon, 22 Apr 2024 18:19:32 +0000 (20:19 +0200)
Signed-off-by: Christoph Heiss <c.heiss@proxmox.com>
proxmox-auto-installer/src/answer.rs
proxmox-auto-installer/src/bin/proxmox-auto-installer.rs

index 16bb46dbd4e3907a1583f0c4e6e00f3e1fa2004e..b82fd6737937dd26ad822213ba971f979a0c94f2 100644 (file)
@@ -16,7 +16,6 @@ pub struct Answer {
     pub network: Network,
     #[serde(rename = "disk-setup")]
     pub disks: Disks,
-    pub system: Option<System>,
 }
 
 #[derive(Clone, Deserialize, Debug)]
@@ -30,6 +29,8 @@ pub struct Global {
     pub root_password: String,
     #[serde(default)]
     pub reboot_on_error: bool,
+    #[serde(default)]
+    pub root_ssh_keys: Vec<String>,
 }
 
 #[derive(Clone, Deserialize, Debug, Default, PartialEq)]
@@ -262,10 +263,3 @@ pub struct BtrfsOptions {
     pub hdsize: Option<f64>,
     pub raid: Option<BtrfsRaidLevel>,
 }
-
-#[derive(Clone, Default, Deserialize, Debug)]
-#[serde(deny_unknown_fields)]
-pub struct System {
-    #[serde(default)]
-    pub root_ssh_keys: Vec<String>,
-}
index 1040ef60c9e3073cb01c2f74d0454562daa95fd3..0ed27296bba7a45268382b52c374794a1e8ed2a8 100644 (file)
@@ -193,23 +193,21 @@ fn run_installation(
 }
 
 fn run_postinstallation(answer: &Answer) {
-    if let Some(system) = &answer.system {
-        if !system.root_ssh_keys.is_empty() {
-            // FIXME: move handling this into the low-level installer and just pass in installation
-            // config, as doing parts of the installation/configuration here and parts in the
-            // low-level installer is not nice (seemingly spooky actions at a distance).
-            info!("Adding root ssh-keys to the installed system ..");
-            run_cmds(
-                "ssh-key-setup",
-                true,
-                &[
-                    "mkdir -p /target/root/.ssh",
-                    &format!(
-                        "printf '{}' >>/target/root/.ssh/authorized_keys",
-                        system.root_ssh_keys.join("\n"),
-                    ),
-                ],
-            );
-        }
+    if !answer.global.root_ssh_keys.is_empty() {
+        // FIXME: move handling this into the low-level installer and just pass in installation
+        // config, as doing parts of the installation/configuration here and parts in the
+        // low-level installer is not nice (seemingly spooky actions at a distance).
+        info!("Adding root ssh-keys to the installed system ..");
+        run_cmds(
+            "ssh-key-setup",
+            true,
+            &[
+                "mkdir -p /target/root/.ssh",
+                &format!(
+                    "printf '{}' >>/target/root/.ssh/authorized_keys",
+                    answer.global.root_ssh_keys.join("\n"),
+                ),
+            ],
+        );
     }
 }