I'm new in ansible, but I've been trying to arrange properly my inventory (100 servers give or take) by environment, something like:
[dev]
server1
server2
[qa]
server3
server4
[prod]
server5
server6
There's nothing on the name of these servers to identify what environment these belong to: (dev/qa/prod) but to connect to each one of these and retrieve a file /foo/var/file present in each server that shows the environment of the server
so far, I've created this
---
- hosts: ALL
gather_facts: no
tasks:
- name: return environment to registered var
shell: 'cat /foo/var/file'
register: environment
- template:
src: template.csv.j2
dest: list.csv
delegate_to: localhost
with_items: {{ environment }}
template is:
{% for x in environment %}
['x']
{{ host }}
{% endfor %}
So I'm just trying to retrieve these values to be able to create some sort of inventory with these
what would be the best way to create this inventory?