On 26.04.2019 14:09, John Simmons wrote: > - name: sucess notification message via Slack > slack: > token: "*******************************" > msg: "some message" > username: 'Ansible' > link_names: 0 > parse: 'none' > color: 'good' #normal, good, warning, danger > delegate_to: localhost > when: *command_output.stdout | length > 0* > ignore_errors: yes > > ######################################## > > and this is the output form the command line: > > TASK [success notification message via Slack] > ***************************************************************** > skipping: [10.*.0.138] > *ok: [10.*.0.137 -> localhost]* > > ######################################## > > As the task is looking in the logs on both of these hosts will only find > the entry on 1 of the hosts, and therefore only send the message from the > server that could actually find the log and not from both servers so that > the slack channel is not getting bombarded with blank messages from the > host that didn't have then log entry. > > > > This is all fine until I want to run another play as an alert if both hosts > skipped the task due to the log not existing on either host. So for example > this: > > TASK [success notification message via Slack] > ***************************************************************** > *skipping: [10.*.0.137]* > > *skipping: [10.*.0.138]* > > ######################################## > > How could I get around this? and is it even possible?
You would need to check them both with something like(list in when is the same as logical AND) when: - hostvars['10.*.0.137'].command_output.stdout | length > 0 - hostvars['10.*.0.138'].command_output.stdout | length > 0 -- Kai Stian Olstad -- 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 post to this group, send email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/2be7b151-c491-94c1-9b86-4a87cc2449fb%40olstad.com. For more options, visit https://groups.google.com/d/optout.
