add static inventory generation

This commit is contained in:
Chris Hammer 2022-09-12 11:22:35 -04:00
parent fe8064784e
commit 8cc63c3ad8
5 changed files with 1002039 additions and 1 deletions

1
.gitignore vendored
View File

@ -1,3 +1,2 @@
collections/ansible_collections collections/ansible_collections
__old
facts.d facts.d

15
csv_static_inventory.yml Normal file
View File

@ -0,0 +1,15 @@
---
- name: CSV Inventory Creation
hosts: all
become: no
gather_facts: no
vars_files:
- vars/defaults.yml
tasks:
- import_tasks: tasks/generate_static_from_csv.yml
...

1002000
files/csv_static_inventory.ini Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,15 @@
---
- name: Read in CSV contents
read_csv :
path : "{{ playbook_dir }}/files/{{ __csv_file }}"
register : r_csv_inventory
delegate_to : localhost
- name: Write inventory from CSV data
template:
src : templates/csv_static_inventory.j2
dest : "{{ playbook_dir }}/files/csv_static_inventory.ini"
...

View File

@ -0,0 +1,9 @@
{% for csv_group in r_csv_inventory.list %}
[{{ csv_group.tower_group }}]
{% for csv_host in r_csv_inventory.list %}
{% if csv_host.tower_group == csv_group.tower_group %}
{{ csv_host.inventory_name }}
{% endif %}
{% endfor %}
{% endfor %}