Let's just create a role that populates the Linode inventory..

This commit is contained in:
Kevin Thompson
2025-04-27 13:36:55 -05:00
parent 424dc8653b
commit 83932105ef
4 changed files with 80 additions and 7 deletions

View File

@@ -0,0 +1,17 @@
---
- name: Run Linode dynamic inventory script
ansible.builtin.command: "{{ playbook_dir }}/roles/inventory/linode_inventory/files/linode_inventory.py"
register: linode_inventory_raw
changed_when: false
- name: Parse JSON inventory output
ansible.builtin.set_fact:
linode_inventory: "{{ linode_inventory_raw.stdout | from_json }}"
- name: Add Linode hosts dynamically
ansible.builtin.add_host:
name: "{{ item.key }}"
ansible_host: "{{ item.value.ansible_host }}"
groups: all
loop: "{{ linode_inventory['_meta']['hostvars'] | dict2items }}"