nixos-servers/inventory
Torjus Håkestad 002f934c70
Some checks failed
Run nix flake check / flake-check (push) Failing after 27m26s
Periodic flake update / flake-update (push) Successful in 1m24s
Add ansible and playbook to trigger upgrade
2025-02-07 00:28:05 +01:00

32 lines
618 B
Python
Executable File

#!/usr/bin/env python
import json
import subprocess
IGNORED_HOSTS = [
"inc1",
"inc2",
"media1",
"nixos-test1",
"ns3",
"ns4",
"template1",
]
result = subprocess.run(["nix", "flake", "show", "--json"], stdout=subprocess.PIPE, stderr=subprocess.DEVNULL)
results = json.loads(result.stdout)
configs = results.get("nixosConfigurations")
hosts = [x for x in configs.keys() if x not in IGNORED_HOSTS]
output = {
"all": {
"hosts": hosts,
"vars": {
"ansible_python_interpreter": "/run/current-system/sw/bin/python3"
},
}
}
print(json.dumps(output))