Add inventory role for Linode

This commit is contained in:
2025-05-11 00:01:33 -05:00
parent adf16d3db8
commit b7e6b1af07
3 changed files with 110 additions and 0 deletions

View File

@@ -0,0 +1,19 @@
---
- name: Fetch Linode instances
linode.cloud.linode_instance_info:
api_token: "{{ linode_token }}"
register: linodes
- name: Build inventory lines
set_fact:
linode_inventory: |
{% for linode in linodes.data %}
{{ linode.label }} ansible_host={{ linode.ipv4[0] }} {% for tag in linode.tags %}group_{{ tag }}=true {% endfor %}
{% endfor %}
- name: Write dynamic inventory to file
copy:
dest: /tmp/linode_inventory.ini
content: |
[all]
{{ linode_inventory }}