Created
June 26, 2019 18:10
-
-
Save xandout/7aab2e769fbf1fa138d22a3f29be51b7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1561572401,horse-uat,Ubuntu,16,16.04,xenial | |
1561572405,moose-uat,Ubuntu,16,16.04,xenial | |
1561572408,duck-uat,Ubuntu,16,16.04,xenial | |
1561572413,goat-uat,Ubuntu,16,16.04,xenial | |
1561572415,horse-dev,Ubuntu,16,16.04,xenial | |
1561571759,moose-dev,Amazon,2016,NA,NA | |
1561572422,duck-dev,Ubuntu,16,16.04,xenial | |
1561572426,goat-dev,Ubuntu,14,14.04,trusty |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
# First, clear the local CSV | |
- hosts: localhost | |
tasks: | |
- name: Clear | |
copy: | |
content: '' | |
dest: "hosts.csv" | |
run_once: True | |
delegate_to: 127.0.0.1 | |
# Now write a line per host | |
- hosts: all | |
serial: 1 | |
tasks: | |
- name: Write | |
lineinfile: | |
dest: "hosts.csv" | |
line: '{{ ansible_date_time.epoch }},{{ inventory_hostname }},{{ ansible_distribution }},{{ ansible_distribution_major_version }},{{ ansible_distribution_version }},{{ ansible_distribution_release | default("NONE") }}' | |
delegate_facts: yes | |
delegate_to: 127.0.0.1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment