Sorry, same issue. I have 2 hosts in my play. I stopped chronyd on the
first host. The service was started on server 1 and didn't need to be
started on server 2. The email that came over has both hosts listed in it
still.
[root@ansible ~]#ansible-playbook check_services.yml -K
BECOME password:
PLAY
[services]***********************************************************************************************************************************************
TASK [setup]
*************************************************************************************************************************************************
ok: [server1]
ok: [server2]
TASK [Start chronyd if not started]
**************************************************************************************************************************
changed: [server1]
ok: [server2]
TASK [Prepare report]
****************************************************************************************************************************************
changed: [server1]
TASK [Send report to admins]
*****************************************************************************************************************************
ok: [server1]
TASK [Delete local output file]
******************************************************************************************************************************
changed: [server1]
PLAY RECAP
***************************************************************************************************************************************************
server1 : ok=5 changed=3 unreachable=0 failed=0 skipped=0
rescued=0 ignored=0
server2 : ok=2 changed=0 unreachable=0 failed=0 skipped=0
rescued=0 ignored=0
Email:
Service Check
Date generated: 03/01/2021 14:54:03
---
Host: server1
chronyd state: started
---
Host: server2
chronyd state: started
We want to only have server1 be listed since its state actually changed.
Thanks,
Harry
On Monday, March 1, 2021 at 2:21:00 PM UTC-5 Brian Coca wrote:
> {% if chrony is changed %}
> {% for i in play_hosts | sort %}
> Host: {{ i }}
> chronyd state: {{ hostvars[i]['chrony']['state'] }}
> {% endfor %}
> {% endif %}
>
>
>
> --
> ----------
> Brian Coca
>
>
--
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/e8dac7cf-9f65-454f-87a2-12646a346f8cn%40googlegroups.com.