cli/install: add --no-persist-state
Skip persisting the current date after successful install This is a workaround due to incomplete test setup - installing a clan machine without having a clan
This commit is contained in:
@@ -232,6 +232,7 @@
|
||||
"-i", ssh_conn.ssh_key,
|
||||
"--option", "store", os.environ['CLAN_TEST_STORE'],
|
||||
"--update-hardware-config", "nixos-facter",
|
||||
"--no-persist-state",
|
||||
]
|
||||
|
||||
subprocess.run(clan_cmd, check=True)
|
||||
|
||||
@@ -91,6 +91,7 @@ def install_command(args: argparse.Namespace) -> None:
|
||||
no_reboot=args.no_reboot,
|
||||
build_on=args.build_on if args.build_on is not None else None,
|
||||
update_hardware_config=HardwareConfig(args.update_hardware_config),
|
||||
persist_state=not args.no_persist_state,
|
||||
),
|
||||
target_host=remote,
|
||||
)
|
||||
@@ -137,6 +138,12 @@ def register_install_parser(parser: argparse.ArgumentParser) -> None:
|
||||
help="update the hardware configuration",
|
||||
choices=[x.value for x in HardwareConfig],
|
||||
)
|
||||
parser.add_argument(
|
||||
"--no-persist-state",
|
||||
action="store_true",
|
||||
help="Disable persisting the result of the installation after it is done",
|
||||
default=False,
|
||||
)
|
||||
|
||||
parser.add_argument(
|
||||
"--phases",
|
||||
|
||||
@@ -56,6 +56,7 @@ class InstallOptions:
|
||||
phases: str | None = None
|
||||
build_on: BuildOn | None = None
|
||||
update_hardware_config: HardwareConfig = HardwareConfig.NONE
|
||||
persist_state: bool = True
|
||||
|
||||
|
||||
@API.register
|
||||
@@ -227,6 +228,7 @@ def run_machine_install(opts: InstallOptions, target_host: Remote) -> None:
|
||||
RunOpts(log=Log.BOTH, prefix=machine.name, needs_user_terminal=True),
|
||||
)
|
||||
|
||||
if opts.persist_state:
|
||||
inventory_store = InventoryStore(machine.flake)
|
||||
inventory = inventory_store.read()
|
||||
|
||||
@@ -236,7 +238,6 @@ def run_machine_install(opts: InstallOptions, target_host: Remote) -> None:
|
||||
# Cut of the milliseconds
|
||||
int(time()),
|
||||
)
|
||||
|
||||
inventory_store.write(
|
||||
inventory, f"Installed {machine.name} at {target_host.target}"
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user