Hello everyone,
I was trying to loop through all my hosts and if a certain package (xauth
in this case) was present it would create a list and email that list with
this information:
If package was found:
*HOSTNAME - PACKAGE_NAME:VERSION*
If package was not found:
*PACKAGE_NAME Not Found on HOSTNAME*
I thought this would work but it does not.
- name: GATHER INSTALLED PACKAGES INFORMATION
package_facts:
manager: auto
strategy: all
ignore_errors: True
#
#
- name: SET FACT FOR PACKAGE PRESENCE
set_fact:
package_presence: "{{ ansible_facts.packages['xauth'] }}"
ignore_errors: True
#
#
- name: LIST HOSTNAME, PACKAGE NAME AND VERSION IF PRESENT
set_fact:
machine_info:
"{% for host in ansible_play_batch %}{% if package_presence is
defined %}{{ hostvars[host]['ansible_hostname'] }} - {{
hostvars[host]['ansible_facts']['packages']['xauth'][0]['name'] }}:{{
hostvars[host]['ansible_facts']['packages']['xauth'][0]['version'] }}<br>{%
else %}XAUTH Not Found on {{ hostvars[host] }}<br>{% endif
%}{% endfor %}"
run_once: yes
ignore_errors: True
This is the error I receive:
*The task includes an option with an undefined variable. The error was:
'dict object' has no attribute 'xauth'\n\nThe error appears to be in
'/var/lib/awx/projects/roles/Package_Information/tasks/main.yml': line 21,
column 3, but may\nbe elsewhere in the file depending on the exact syntax
problem.\n\nThe offending line appears to be:\n\n#\n- name: **LIST
HOSTNAME, PACKAGE NAME AND VERSION IF PRESENT\n ^ here\n",*
--
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 [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/3bead462-9149-4a34-a952-29140baae795n%40googlegroups.com.