- name: SET FACT FOR ANSIBLE FACTS
set_fact:
machine_os: "{{ ansible_facts }}"
#
#
- name: DISTRIBUTION AND MAJOR VERSION
debug:
msg: "{% for os in machine_os %}{{ os.ansible_hostname }} - {{
os.ansible_distribution }} {{ os.ansible_distribution_version }}{%
endfor %}"
Would anyone know how I could generate this list of information for all
my machines to send via email?
Please give this a try:
- name: Collect information on all machines
set_fact:
machine_info: |
{% for host in ansible_play_hosts %}
{{ hostvars[host]['ansible_hostname'] }} - {{ hostvars[host]['ansible_distribution'] }} {{ hostvars[host]['ansible_distribution_version'] }}
{% endfor %}
run_once: yes