diff --git a/manual/src/release-notes.md b/manual/src/release-notes.md index f512d38..57d39ed 100644 --- a/manual/src/release-notes.md +++ b/manual/src/release-notes.md @@ -13,6 +13,7 @@ - The [`meta.nodeSpecialArgs`](./reference/meta.md#nodespecialargs) option has been added. It allows specifying node-specific `specialArgs` passed to NixOS modules ([#100](https://github.com/zhaofengli/colmena/pull/100)). - The [`repl`](./reference/cli.html#colmena-repl) subcommand has been added. It allows you to start an [interactive REPL](./features/eval.md#interactive-repl) with access to the complete node configurations. - The default goal for `colmena apply` is now `boot` if `--reboot` is specified, and `switch` otherwise ([#113](https://github.com/zhaofengli/colmena/issues/113)). +- Post-activation keys are now uploaded after the reboot if `--reboot` is specified ([#113](https://github.com/zhaofengli/colmena/issues/113)). ## [Release 0.3.1](https://github.com/zhaofengli/colmena/releases/tag/v0.3.1) (2022/08/18) diff --git a/src/nix/deployment/mod.rs b/src/nix/deployment/mod.rs index 494829b..c0363ca 100644 --- a/src/nix/deployment/mod.rs +++ b/src/nix/deployment/mod.rs @@ -632,8 +632,35 @@ impl Deployment { Ok(target) }).await?; + // Reboot + let mut target = if self.options.reboot { + let job = parent.create_job(JobType::Reboot, nodes.clone())?; + let arc_self = self.clone(); + job.run(|job| async move { + let host = target.host.as_mut().unwrap(); + host.set_job(Some(job.clone())); + + let new_profile = if arc_self.goal.persists_after_reboot() { + Some(profile) + } else { + None + }; + + let options = RebootOptions::default() + .wait_for_boot(true) + .new_profile(new_profile); + + host.reboot(options).await?; + + Ok(target) + }) + .await? + } else { + target + }; + // Upload post-activation keys - let mut target = if self.options.upload_keys { + if self.options.upload_keys { let job = parent.create_job(JobType::UploadKeys, nodes.clone())?; job.run_waiting(|job| async move { let keys = target @@ -646,7 +673,7 @@ impl Deployment { if keys.is_empty() { job.noop("No post-activation keys to upload".to_string())?; - return Ok(target); + return Ok(()); } job.state(JobState::Running)?; @@ -657,33 +684,6 @@ impl Deployment { host.upload_keys(&keys, true).await?; job.success_with_message("Uploaded keys (post-activation)".to_string())?; - Ok(target) - }) - .await? - } else { - target - }; - - // Reboot - if self.options.reboot { - let job = parent.create_job(JobType::Reboot, nodes.clone())?; - let arc_self = self.clone(); - job.run(|job| async move { - let host = target.host.as_mut().unwrap(); - host.set_job(Some(job.clone())); - - let new_profile = if arc_self.goal.persists_after_reboot() { - Some(profile) - } else { - None - }; - - let options = RebootOptions::default() - .wait_for_boot(true) - .new_profile(new_profile); - - host.reboot(options).await?; - Ok(()) }) .await?;