Add ansible and playbook to trigger upgrade
This commit is contained in:
parent
fbcb81291b
commit
002f934c70
19
flake.nix
19
flake.nix
@ -32,6 +32,14 @@
|
||||
config.allowUnfree = true;
|
||||
};
|
||||
};
|
||||
allSystems = [
|
||||
"x86_64-linux"
|
||||
"aarch64-linux"
|
||||
"x86_64-darwin"
|
||||
"aarch64-darwin"
|
||||
];
|
||||
forAllSystems =
|
||||
f: nixpkgs.lib.genAttrs allSystems (system: f { pkgs = import nixpkgs { inherit system; }; });
|
||||
in
|
||||
{
|
||||
nixosConfigurations = {
|
||||
@ -297,5 +305,16 @@
|
||||
];
|
||||
};
|
||||
};
|
||||
devShells = forAllSystems (
|
||||
{ pkgs }:
|
||||
{
|
||||
default = pkgs.mkShell {
|
||||
packages = with pkgs; [
|
||||
ansible
|
||||
python3
|
||||
];
|
||||
};
|
||||
}
|
||||
);
|
||||
};
|
||||
}
|
||||
|
31
inventory
Executable file
31
inventory
Executable file
@ -0,0 +1,31 @@
|
||||
#!/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))
|
9
playbooks/run-upgrade.yml
Normal file
9
playbooks/run-upgrade.yml
Normal file
@ -0,0 +1,9 @@
|
||||
---
|
||||
- name: Trigger nixos-upgrade job on all hosts
|
||||
hosts: all
|
||||
remote_user: root
|
||||
|
||||
tasks:
|
||||
- ansible.builtin.systemd_service:
|
||||
name: nixos-upgrade.service
|
||||
state: started
|
@ -4,5 +4,6 @@
|
||||
pkgs.git
|
||||
pkgs.jq
|
||||
pkgs.kitty.terminfo
|
||||
pkgs.python3
|
||||
];
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user