Merge pull request 'pkgs/cli: Query target-host for machines install from configuration' (#2359) from kenji/clan-core:kenji-cli/2309/machines-install into main
This commit is contained in:
@@ -105,7 +105,7 @@
|
||||
client.succeed("test -f test-flake/machines/test-install-machine/hardware-configuration.nix")
|
||||
client.succeed("clan machines update-hardware-config --backend nixos-facter --flake test-flake test-install-machine root@target>&2")
|
||||
client.succeed("test -f test-flake/machines/test-install-machine/facter.json")
|
||||
client.succeed("clan machines install --debug --flake ${../..} --yes test-install-machine root@target >&2")
|
||||
client.succeed("clan machines install --debug --flake ${../..} --yes test-install-machine --target-host root@target >&2")
|
||||
try:
|
||||
target.shutdown()
|
||||
except BrokenPipeError:
|
||||
|
||||
@@ -112,7 +112,7 @@ This process involves preparing a suitable hardware and disk partitioning config
|
||||
1. **SSH with Password Authentication**
|
||||
Run the following command to install using SSH:
|
||||
```bash
|
||||
clan machines install [MACHINE] <IP>
|
||||
clan machines install [MACHINE] --target-host <IP>
|
||||
```
|
||||
|
||||
2. **Scanning a QR Code for Installation Details**
|
||||
@@ -133,7 +133,7 @@ This process involves preparing a suitable hardware and disk partitioning config
|
||||
Replace `<target_host>` with the **target computers' ip address**:
|
||||
|
||||
```bash
|
||||
clan machines install [MACHINE] <target_host>
|
||||
clan machines install [MACHINE] --target-host <target_host>
|
||||
```
|
||||
|
||||
|
||||
|
||||
@@ -96,7 +96,7 @@ blkdiscard /dev/disk/by-id/nvme-eui.002538b931b59865
|
||||
4. Run the `clan` machine installation with the following command:
|
||||
|
||||
```bash
|
||||
clan machines install gchq-local root@nixos-installer --yes --no-reboot
|
||||
clan machines install gchq-local --target-host root@nixos-installer --yes --no-reboot
|
||||
```
|
||||
|
||||
### Step 2: ZFS Pool Import and System Installation
|
||||
|
||||
@@ -329,8 +329,10 @@ Examples:
|
||||
Will update the specified machine [MACHINE], if [MACHINE] is omitted, the command
|
||||
will attempt to update every configured machine.
|
||||
|
||||
$ clan machines install [MACHINES] [TARGET_HOST]
|
||||
Will install the specified machine [MACHINE], to the specified [TARGET_HOST].
|
||||
$ clan machines install [MACHINE] --target-host [TARGET_HOST]
|
||||
Will install the specified machine [MACHINE] to the specified [TARGET_HOST].
|
||||
If the `--target-host` flag is omitted will try to find host information by
|
||||
checking the deployment configuration inside the specified machine.
|
||||
|
||||
For more detailed information, visit: {help_hyperlink("deploy", "https://docs.clan.lol/deploy")}
|
||||
"""
|
||||
|
||||
@@ -99,8 +99,10 @@ This subcommand provides an interface to install machines managed by clan.
|
||||
|
||||
Examples:
|
||||
|
||||
$ clan machines install [MACHINE] [TARGET_HOST]
|
||||
Will install the specified machine [MACHINE], to the specified [TARGET_HOST].
|
||||
$ clan machines install [MACHINE] --target-host [TARGET_HOST]
|
||||
Will install the specified machine [MACHINE] to the specified [TARGET_HOST].
|
||||
If the `--target-host` flag is omitted will try to find host information by
|
||||
checking the deployment configuration inside the specified machine.
|
||||
|
||||
$ clan machines install [MACHINE] --json [JSON]
|
||||
Will install the specified machine [MACHINE] to the host exposed by
|
||||
|
||||
@@ -135,16 +135,20 @@ def install_command(args: argparse.Namespace) -> None:
|
||||
elif args.png:
|
||||
json_ssh_deploy = json.loads(qrcode_scan(args.png))
|
||||
|
||||
if not json_ssh_deploy and not args.target_host:
|
||||
msg = "No target host provided, please provide a target host."
|
||||
raise ClanError(msg)
|
||||
|
||||
if json_ssh_deploy:
|
||||
target_host = f"root@{find_reachable_host_from_deploy_json(json_ssh_deploy)}"
|
||||
password = json_ssh_deploy["pass"]
|
||||
else:
|
||||
elif args.target_host:
|
||||
target_host = args.target_host
|
||||
password = None
|
||||
else:
|
||||
machine = Machine(name=args.machine, flake=args.flake, nix_options=args.option)
|
||||
target_host = str(machine.target_host)
|
||||
password = None
|
||||
|
||||
if not target_host:
|
||||
msg = "No target host provided, please provide a target host."
|
||||
raise ClanError(msg)
|
||||
|
||||
if not args.yes:
|
||||
ask = input(f"Install {args.machine} to {target_host}? [y/N] ")
|
||||
@@ -223,18 +227,16 @@ def register_install_parser(parser: argparse.ArgumentParser) -> None:
|
||||
)
|
||||
add_dynamic_completer(machines_parser, complete_machines)
|
||||
|
||||
parser.add_argument(
|
||||
"target_host",
|
||||
type=str,
|
||||
nargs="?",
|
||||
help="ssh address to install to in the form of user@host:2222",
|
||||
)
|
||||
group = parser.add_mutually_exclusive_group(required=False)
|
||||
group.add_argument(
|
||||
"-j",
|
||||
"--json",
|
||||
help="specify the json file for ssh data (generated by starting the clan installer)",
|
||||
)
|
||||
group.add_argument(
|
||||
"--target-host",
|
||||
help="ssh address to install to in the form of user@host:2222",
|
||||
)
|
||||
group.add_argument(
|
||||
"-P",
|
||||
"--png",
|
||||
|
||||
Reference in New Issue
Block a user