swarmctl: interactive setup walks the first-run ceremony
swarmctl setup with no subcommand checks the setup status first, then takes the open steps one at a time: prompts for input, shows a running action as one live line, prints the store keys, root token and new password under a warning until the operator confirms, and names the deploy option for a step this host cannot do. It calls the code of bao init, bao grant-bootstrap, user add, forge make-admin, agent create, agent permissions set and agent set-state. Refuses without root or a terminal.
This commit is contained in:
parent
4fae6a7766
commit
44caa72c19
1 changed files with 2172 additions and 82 deletions
|
|
@ -15,6 +15,12 @@ use crate::remote::Target;
|
|||
///
|
||||
/// Synchronous for the same reason `agent create` is.
|
||||
pub(crate) fn make_admin(target: &Target, name: &str) -> Result<()> {
|
||||
println!("{}", request_admin(target, name)?);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// The round trip of [`make_admin`]: the sentence it prints, not printed.
|
||||
pub(crate) fn request_admin(target: &Target, name: &str) -> Result<String> {
|
||||
let name = parse_ident(name, "user name")?;
|
||||
|
||||
let rt = tokio::runtime::Builder::new_current_thread()
|
||||
|
|
@ -28,9 +34,8 @@ pub(crate) fn make_admin(target: &Target, name: &str) -> Result<()> {
|
|||
"forge-make-admin",
|
||||
))?;
|
||||
|
||||
match resp.change {
|
||||
ForgeAdminChange::Promoted => println!("forge: {name:?} is now a site admin"),
|
||||
ForgeAdminChange::AlreadyAdmin => println!("forge: {name:?} was already a site admin"),
|
||||
}
|
||||
Ok(())
|
||||
Ok(match resp.change {
|
||||
ForgeAdminChange::Promoted => format!("forge: {name:?} is now a site admin"),
|
||||
ForgeAdminChange::AlreadyAdmin => format!("forge: {name:?} was already a site admin"),
|
||||
})
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue