fucking hell

This commit is contained in:
2025-08-07 13:51:26 -05:00
parent eae894e681
commit c5851bd287
3 changed files with 39 additions and 212 deletions

View File

@@ -123,13 +123,13 @@
label: "{{ item.key }}"
when: linode_inventory_data._meta.hostvars | length > 0
- name: Create static inventory file (optional)
- name: Create JSON inventory file for AWX
ansible.builtin.template:
src: inventory.ini.j2
dest: "{{ linode_inventory_output_dir }}/linode_static_inventory.ini"
src: linode_hosts.json.j2
dest: "{{ linode_inventory_output_dir }}/linode_hosts.json"
mode: '0644'
when: inventory_format == "ini"
delegate_to: localhost
when: linode_inventory_data is defined
- name: Clean up temporary script
ansible.builtin.file:

View File

@@ -0,0 +1,35 @@
{
"_meta": {
"hostvars": {
{% for host, vars in linode_inventory_data._meta.hostvars.items() %}
"{{ host }}": {
"ansible_host": "{{ vars.ansible_host }}",
"ansible_user": "phlux",
"linode_id": {{ vars.linode_id }},
"linode_label": "{{ vars.linode_label }}",
"linode_region": "{{ vars.linode_region }}",
"linode_type": "{{ vars.linode_type }}",
"linode_status": "{{ vars.linode_status }}",
"linode_ipv4": {{ vars.linode_ipv4 | to_json }},
"linode_ipv6": "{{ vars.linode_ipv6 | default('') }}",
"linode_tags": {{ vars.linode_tags | to_json }},
"is_debian": {{ vars.is_debian | lower }},
"is_ubuntu": {{ vars.is_ubuntu | lower }},
"is_k3s": {{ vars.is_k3s | lower }},
"is_control_plane": {{ vars.is_control_plane | lower }},
"is_worker_node": {{ vars.is_worker_node | lower }},
"tag_string": "{{ vars.tag_string }}"
}{% if not loop.last %},{% endif %}
{% endfor %}
}
},
"all": {
"children": {{ linode_inventory_data.all.children | to_json }}
},
"ungrouped": {
"hosts": {{ linode_inventory_data.ungrouped.hosts | to_json }}
}{% for group_name, group_data in linode_inventory_data.items() %}{% if group_name not in ['_meta', 'all', 'ungrouped'] %},
"{{ group_name }}": {
"hosts": {{ group_data.hosts | to_json }}
}{% endif %}{% endfor %}
}