aboutsummaryrefslogtreecommitdiffstats
path: root/inventory
diff options
context:
space:
mode:
Diffstat (limited to 'inventory')
-rw-r--r--inventory3
-rwxr-xr-xinventory/jails.py33
-rw-r--r--inventory/prod/hosts.yml22
l---------inventory/prod/jails.py1
-rw-r--r--inventory/test/hosts.yml34
l---------inventory/test/jails.py1
6 files changed, 91 insertions, 3 deletions
diff --git a/inventory b/inventory
deleted file mode 100644
index 05bdd3a..0000000
--- a/inventory
+++ /dev/null
@@ -1,3 +0,0 @@
-[hosts]
-pursotin
-test_vm
diff --git a/inventory/jails.py b/inventory/jails.py
new file mode 100755
index 0000000..0458dc0
--- /dev/null
+++ b/inventory/jails.py
@@ -0,0 +1,33 @@
+#!/usr/bin/env python3
+"""Dynamic inventory script that discovers jails from roles/jails/."""
+import json
+import os
+import re
+
+def main():
+ # Resolve to project root (one level up from inventory/)
+ script_dir = os.path.dirname(os.path.realpath(__file__))
+ project_root = os.path.dirname(script_dir)
+ jails_dir = os.path.join(project_root, "roles", "jails")
+
+ hosts = []
+ if os.path.isdir(jails_dir):
+ for entry in sorted(os.listdir(jails_dir)):
+ path = os.path.join(jails_dir, entry)
+ if os.path.isdir(path) and re.match(r"^\d+_", entry):
+ name = re.sub(r"^\d+_", "", entry)
+ hosts.append(name)
+
+ inventory = {
+ "jails": {
+ "hosts": hosts,
+ },
+ "_meta": {
+ "hostvars": {},
+ },
+ }
+
+ print(json.dumps(inventory))
+
+if __name__ == "__main__":
+ main()
diff --git a/inventory/prod/hosts.yml b/inventory/prod/hosts.yml
new file mode 100644
index 0000000..eff5ecb
--- /dev/null
+++ b/inventory/prod/hosts.yml
@@ -0,0 +1,22 @@
+all:
+ children:
+ servers:
+ hosts:
+ pursotin:
+ host_roles:
+ - host
+ - host_prod
+ nic_lan: igc0
+ nic_wan: igc1
+ arch: amd64/amd64
+ lan_ipv4_gateway: "192.168.0.1"
+ lan_ipv4_cidr: "192.168.0.10/16"
+ is_prod: true
+ jails:
+ vars:
+ ansible_jail_host: pursotin
+ jail_delegate_host: pursotin
+ jail_lan_cidr: "192.168.2.0/16"
+ jail_lan_offset: 0
+ ssl_enabled: true
+ is_prod: true
diff --git a/inventory/prod/jails.py b/inventory/prod/jails.py
new file mode 120000
index 0000000..d036389
--- /dev/null
+++ b/inventory/prod/jails.py
@@ -0,0 +1 @@
+../jails.py \ No newline at end of file
diff --git a/inventory/test/hosts.yml b/inventory/test/hosts.yml
new file mode 100644
index 0000000..fdf982a
--- /dev/null
+++ b/inventory/test/hosts.yml
@@ -0,0 +1,34 @@
+all:
+ children:
+ servers:
+ hosts:
+ test_vm:
+ ansible_host: 10.0.20.2
+ ansible_user: root
+ ansible_ssh_private_key_file: vm/id_ed25519
+ ansible_ssh_common_args: "-o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o IdentitiesOnly=yes -o IdentityAgent=none"
+ host_roles:
+ - host
+ - host_test
+ nic_lan: vtnet0
+ nic_wan: vtnet0
+ arch: arm64/aarch64
+ dns_nameserver: "10.0.20.1"
+ lan_ipv4_gateway: "10.0.20.1"
+ lan_ipv4_cidr: "10.0.20.2/24"
+ is_prod: false
+ jails:
+ vars:
+ ansible_host: 10.0.20.2
+ ansible_jail_host: 10.0.20.2
+ ansible_user: root
+ ansible_ssh_private_key_file: vm/id_ed25519
+ ansible_ssh_common_args: "-o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o IdentitiesOnly=yes -o IdentityAgent=none"
+ jail_delegate_host: test_vm
+ jail_lan_cidr: "10.0.20.0/24"
+ jail_lan_offset: 100
+ ssl_enabled: false
+ is_prod: false
+ ingress_wan_static: "10.0.20.3/24"
+ dns_nameserver: "10.0.20.1"
+ lan_ipv4_gateway: "10.0.20.1"
diff --git a/inventory/test/jails.py b/inventory/test/jails.py
new file mode 120000
index 0000000..d036389
--- /dev/null
+++ b/inventory/test/jails.py
@@ -0,0 +1 @@
+../jails.py \ No newline at end of file