From 82f614eb473fc3b7253d7cdaa4bdc067114f274d Mon Sep 17 00:00:00 2001 From: aleidk Date: Mon, 14 Jul 2025 09:10:34 -0400 Subject: [PATCH] fix: homelab hosts --- ansible.cfg | 8 ++++---- hosts/homelab.hcloud.yaml | 4 ++++ hosts/proxmox.yaml | 3 ++- pyproject.toml | 1 + uv.lock | 11 +++++++++++ 5 files changed, 22 insertions(+), 5 deletions(-) create mode 100644 hosts/homelab.hcloud.yaml diff --git a/ansible.cfg b/ansible.cfg index 45f1c2c..3772411 100644 --- a/ansible.cfg +++ b/ansible.cfg @@ -35,15 +35,15 @@ ;become_plugins=/home/aleidk/.ansible/plugins/become:/usr/share/ansible/plugins/become # (string) Chooses which cache plugin to use, the default 'memory' is ephemeral. -;fact_caching=memory +fact_caching=jsonfile # (string) Defines connection or path information for the cache plugin -;fact_caching_connection= +fact_caching_connection=~/.cache/ansible/ # (string) Prefix to use for cache plugin files/tables ;fact_caching_prefix=ansible_facts -# (integer) Expiration timeout for the cache plugin data +# (integer) Expiration timeout for the cache plugin data (24 hours by default) ;fact_caching_timeout=86400 # (list) List of enabled callbacks, not all callbacks need enabling, but many of those shipped with Ansible do as we don't want them activated by default. @@ -134,7 +134,7 @@ ;hash_behaviour=replace # (pathlist) Comma separated list of Ansible inventory sources -inventory=/etc/ansible/hosts,./hosts/inventory.yaml,./hosts/proxmox.yaml +inventory=/etc/ansible/hosts,./hosts/inventory.yaml,./hosts/proxmox.yaml,./hosts/homelab.hcloud.yaml # (pathspec) Colon separated paths in which Ansible will search for HttpApi Plugins. ;httpapi_plugins=/home/aleidk/.ansible/plugins/httpapi:/usr/share/ansible/plugins/httpapi diff --git a/hosts/homelab.hcloud.yaml b/hosts/homelab.hcloud.yaml new file mode 100644 index 0000000..e4db050 --- /dev/null +++ b/hosts/homelab.hcloud.yaml @@ -0,0 +1,4 @@ +plugin: hetzner.hcloud.hcloud + +api_token: "{{ lookup('rbw', 'Hetzner Ansible Token').data.password }}" +cache: true diff --git a/hosts/proxmox.yaml b/hosts/proxmox.yaml index 8190d46..ac386b0 100644 --- a/hosts/proxmox.yaml +++ b/hosts/proxmox.yaml @@ -22,6 +22,7 @@ keyed_groups: prefix: distro_ compose: + ansible_host: proxmox_lxc_interfaces | selectattr('name','equalto','eth0') | map(attribute='inet') | first | ansible.utils.ipaddr('address') # ansible_host: proxmox_ipconfig0.ip | default(proxmox_net0.ip) | ansible.utils.ipaddr('address') - ansible_host: proxmox_hostname + ".lan" +# ansible_host: proxmox_hostname + ".internal" ansible_become_method: proxmox_ostyle == "alpine" | ternary("doas", "sudo") diff --git a/pyproject.toml b/pyproject.toml index f4695b3..7091b28 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -6,6 +6,7 @@ readme = "README.md" requires-python = ">=3.13" dependencies = [ "ansible>=11.1.0", + "netaddr>=1.3.0", "paramiko>=3.5.0", "passlib>=1.7.4", ] diff --git a/uv.lock b/uv.lock index a4b1f67..27cf9a3 100644 --- a/uv.lock +++ b/uv.lock @@ -118,6 +118,7 @@ version = "0.1.0" source = { virtual = "." } dependencies = [ { name = "ansible" }, + { name = "netaddr" }, { name = "paramiko" }, { name = "passlib" }, ] @@ -125,6 +126,7 @@ dependencies = [ [package.metadata] requires-dist = [ { name = "ansible", specifier = ">=11.1.0" }, + { name = "netaddr", specifier = ">=1.3.0" }, { name = "paramiko", specifier = ">=3.5.0" }, { name = "passlib", specifier = ">=1.7.4" }, ] @@ -169,6 +171,15 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/4f/65/6079a46068dfceaeabb5dcad6d674f5f5c61a6fa5673746f42a9f4c233b3/MarkupSafe-3.0.2-cp313-cp313t-win_amd64.whl", hash = "sha256:e444a31f8db13eb18ada366ab3cf45fd4b31e4db1236a4448f68778c1d1a5a2f", size = 15739 }, ] +[[package]] +name = "netaddr" +version = "1.3.0" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/54/90/188b2a69654f27b221fba92fda7217778208532c962509e959a9cee5229d/netaddr-1.3.0.tar.gz", hash = "sha256:5c3c3d9895b551b763779ba7db7a03487dc1f8e3b385af819af341ae9ef6e48a", size = 2260504 } +wheels = [ + { url = "https://files.pythonhosted.org/packages/12/cc/f4fe2c7ce68b92cbf5b2d379ca366e1edae38cccaad00f69f529b460c3ef/netaddr-1.3.0-py3-none-any.whl", hash = "sha256:c2c6a8ebe5554ce33b7d5b3a306b71bbb373e000bbbf2350dd5213cc56e3dbbe", size = 2262023 }, +] + [[package]] name = "packaging" version = "24.2"