Re: [ansible-project] How To Get Hostname, OS and Version From Ansible Facts In A List Format?

2021-05-31 Thread Stefan Hornburg (Racke)
On 31.05.21 15:33, 'Marcus Hayhurst' via Ansible Project wrote:
> Hello everyone,
> 
> I'm attempting to get a list of information of all my machines to send
> in an email:
> 
> *Hostname - OS (and) Version *
> 
> so essentially:
> 
> *{{ ansible_hostname }} - {{ ansible_distribution }} {{
> ansible_distribution_version }}* 
> 
> I tried something like this but it does not work:
> 
> - 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

Regards
Racke

> 
> -- 
> You received this message because you are subscribed to the Google
> Groups "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to ansible-project+unsubscr...@googlegroups.com
> .
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/721bdb5c-c602-48aa-a3bc-f23b65b2f73en%40googlegroups.com
> .


-- 
Ecommerce and Linux consulting + Perl and web application programming.
Debian and Sympa administration.

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/a708ce34-edb3-23b7-df56-45801570de49%40linuxia.de.


Re: [ansible-project] How To Get Hostname, OS and Version From Ansible Facts In A List Format?

2021-05-31 Thread Rajthecomputerguy
Can you show me the error message?

On Mon, May 31, 2021 at 7:03 PM 'Marcus Hayhurst' via Ansible Project <
ansible-project@googlegroups.com> wrote:

> Hello everyone,
>
> I'm attempting to get a list of information of all my machines to send in
> an email:
>
> *Hostname - OS (and) Version *
>
> so essentially:
>
> *{{ ansible_hostname }} - {{ ansible_distribution }} {{
> ansible_distribution_version }}*
>
> I tried something like this but it does not work:
>
> - 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?
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to ansible-project+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/721bdb5c-c602-48aa-a3bc-f23b65b2f73en%40googlegroups.com
> 
> .
>


-- 

Thanks,

Pushparaj G

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CAE5Yv1R%2Bh6t7K56hPiCeY3u%2BGTufBF1B7PrwzLG7SAtYNwk%3D8w%40mail.gmail.com.


[ansible-project] How To Get Hostname, OS and Version From Ansible Facts In A List Format?

2021-05-31 Thread 'Marcus Hayhurst' via Ansible Project
Hello everyone,

I'm attempting to get a list of information of all my machines to send in 
an email:

*Hostname - OS (and) Version *

so essentially:

*{{ ansible_hostname }} - {{ ansible_distribution }} {{ 
ansible_distribution_version }}* 

I tried something like this but it does not work:

- 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?

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/721bdb5c-c602-48aa-a3bc-f23b65b2f73en%40googlegroups.com.