feat: add proxmox dynamic inventory

This commit is contained in:
Alexander Navarro 2025-05-29 13:24:30 -04:00
parent 033d3d6371
commit a25d5884ce
2 changed files with 28 additions and 1 deletions

View file

@ -134,7 +134,7 @@
;hash_behaviour=replace ;hash_behaviour=replace
# (pathlist) Comma separated list of Ansible inventory sources # (pathlist) Comma separated list of Ansible inventory sources
inventory=/etc/ansible/hosts,./hosts/inventory.yaml inventory=/etc/ansible/hosts,./hosts/inventory.yaml,./hosts/proxmox.yaml
# (pathspec) Colon separated paths in which Ansible will search for HttpApi Plugins. # (pathspec) Colon separated paths in which Ansible will search for HttpApi Plugins.
;httpapi_plugins=/home/aleidk/.ansible/plugins/httpapi:/usr/share/ansible/plugins/httpapi ;httpapi_plugins=/home/aleidk/.ansible/plugins/httpapi:/usr/share/ansible/plugins/httpapi

27
hosts/proxmox.yaml Normal file
View file

@ -0,0 +1,27 @@
plugin: community.general.proxmox
user: "{{ lookup('rbw', 'Proxmox Ansible Token').data.username }}"
token_id: "{{ lookup('rbw', 'Proxmox Ansible Token').fields[0].value }}"
token_secret: "{{ lookup('rbw', 'Proxmox Ansible Token').data.password }}"
url: "https://10.0.0.10:8006"
validate_certs: false
cache: true
exclude_nodes: true
group_prefix: proxmox_
want_facts: true
groups:
proxmox_all: true
keyed_groups:
- key: proxmox_tags_parsed
separator: ""
prefix: group_
- key: proxmox_ostype
separator: ""
prefix: distro_
compose:
# ansible_host: proxmox_ipconfig0.ip | default(proxmox_net0.ip) | ansible.utils.ipaddr('address')
ansible_host: proxmox_hostname + ".lan"
ansible_become_method: proxmox_ostyle == "alpine" | ternary("doas", "sudo")