init
This commit is contained in:
29
report.yml
Normal file
29
report.yml
Normal file
@@ -0,0 +1,29 @@
|
||||
---
|
||||
- name: Collect OS info and generate report
|
||||
hosts: all
|
||||
gather_facts: yes
|
||||
tasks:
|
||||
- name: Build server info string
|
||||
set_fact:
|
||||
server_info: "{{ inventory_hostname }} - {{ ansible_distribution }} {{ ansible_distribution_version }}"
|
||||
|
||||
- name: Add server info to a central list
|
||||
run_once: true
|
||||
set_fact:
|
||||
os_report: []
|
||||
|
||||
- name: Collect server info into report
|
||||
set_fact:
|
||||
os_report: "{{ os_report + [hostvars[item].server_info] }}"
|
||||
with_items: "{{ ansible_play_hosts }}"
|
||||
run_once: true
|
||||
|
||||
- name: Write report to file on control node
|
||||
copy:
|
||||
dest: "./os-report.txt"
|
||||
content: |
|
||||
{% for line in os_report %}
|
||||
{{ line }}
|
||||
{% endfor %}
|
||||
run_once: true
|
||||
delegate_to: localhost
|
||||
Reference in New Issue
Block a user