Skip to content

Instantly share code, notes, and snippets.

@frock81
Created May 14, 2021 22:26
Show Gist options
  • Save frock81/fe6d22215ce3793401e9efd5f53ca76a to your computer and use it in GitHub Desktop.
Save frock81/fe6d22215ce3793401e9efd5f53ca76a to your computer and use it in GitHub Desktop.
Produces a list with the operating systems being executed on each host
- hosts: all
become: false
vars:
output_file: os.csv
tasks:
- block:
# For permisison setup.
- name: get current user
command: whoami
register: whoami
run_once: true
- name: clean file
copy:
dest: "{{ output_file }}"
content: 'hostname,distribution,version,release'
owner: "{{ whoami.stdout }}"
run_once: true
- name: fill os information
lineinfile:
path: "{{ output_file }}"
line: "{{ ansible_hostname }},\
{{ ansible_distribution }},\
{{ ansible_distribution_version }},\
{{ ansible_distribution_release }}"
# Tries to prevent concurrent writes.
throttle: 1
delegate_to: localhost
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment