#!/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))