fix case when secrets are regenerated during update/install

This commit is contained in:
Jörg Thalheim
2024-04-12 14:38:21 +02:00
parent 5e19717254
commit 448d752db1
3 changed files with 101 additions and 89 deletions

View File

@@ -81,6 +81,12 @@ class Machine:
self.vm: QMPWrapper = QMPWrapper(state_dir)
def flush_caches(self) -> None:
self._deployment_info = None
self._flake_path = None
self.build_cache.clear()
self.eval_cache.clear()
def __str__(self) -> str:
return f"Machine(name={self.data.name}, flake={self.data.flake_id})"

View File

@@ -96,6 +96,11 @@ def deploy_nixos(hosts: HostGroup) -> None:
ssh_arg = f"-p {h.port}" if h.port else ""
env = os.environ.copy()
env["NIX_SSHOPTS"] = ssh_arg
machine: Machine = h.meta["machine"]
generate_facts(machine)
upload_secrets(machine)
path = upload_sources(".", target)
if h.host_key_check != HostKeyCheck.STRICT:
@@ -105,11 +110,6 @@ def deploy_nixos(hosts: HostGroup) -> None:
ssh_arg += " -i " + h.key if h.key else ""
machine: Machine = h.meta["machine"]
generate_facts(machine)
upload_secrets(machine)
extra_args = h.meta.get("extra_args", [])
cmd = [
"nixos-rebuild",