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:
Johannes Kirschbauer
2025-08-20 20:46:44 +02:00
parent 05951ffdb9
commit e6981ddd72
3 changed files with 22 additions and 13 deletions

View File

@@ -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)
@@ -275,7 +276,7 @@
"${self.checks.x86_64-linux.clan-core-for-checks}",
"${closureInfo}"
)
# Set up SSH connection
ssh_conn = setup_ssh_connection(
target,

View File

@@ -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",

View File

@@ -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,16 +228,16 @@ def run_machine_install(opts: InstallOptions, target_host: Remote) -> None:
RunOpts(log=Log.BOTH, prefix=machine.name, needs_user_terminal=True),
)
inventory_store = InventoryStore(machine.flake)
inventory = inventory_store.read()
if opts.persist_state:
inventory_store = InventoryStore(machine.flake)
inventory = inventory_store.read()
set_value_by_path(
inventory,
f"machine.{machine.name}.installedAt",
# Cut of the milliseconds
int(time()),
)
inventory_store.write(
inventory, f"Installed {machine.name} at {target_host.target}"
)
set_value_by_path(
inventory,
f"machine.{machine.name}.installedAt",
# Cut of the milliseconds
int(time()),
)
inventory_store.write(
inventory, f"Installed {machine.name} at {target_host.target}"
)