I am trying to create a report of failed servers output.
Here is my playbook
---
- hosts: all
gather_facts: no
tasks:
- name: "Runing mksysb backup"
mksysb:
name: "{{inventory_hostname}}.mksysb"
storage_path: /backup
exclude_files: yes
register: mksys
Clearly your when condition doesn't match. But in order to know why, we'd
need to see the content of a failed backup, and maybe a sample success
output as well.
So post that/those.
On Sun, 26 Feb 2023 at 16:32, Kenady Inampudi wrote:
> I am trying to create a report of failed servers output.
>
>
Please find the task output below, usually all the jobs go to changed state
true and the play successfully so i have passed a failed when condition to
identify the failure
--
TASK [Runing mksysb backup]
***
I tried running your code on my local machine. Of course I don't have
"mksysb" so I had to substitute things I've got, but your logic with
respect to "failed_when:" and "hostvars[host]['mksys']['msg']" appears to
be okay.
The only thing that stuck out to me is that you have some leading tabs in
Hi Todd,
my original playbook works just fine, the problem is with the second one
where i want the report just for the failed ones, my first play book give
me all the output due to special variable {% for host in ansible_play_hosts_all
%}
I tried to use if condition to filter the result of the
On Sun, 26 Feb 2023 18:11:02 -0800 (PST)
Kenady Inampudi wrote:
> {% for host in ansible_play_hosts_all %}
> {% if 'Completed Successfully' not in hostvars[host]['mksys']['msg'] %}
>
> This condition generates nothing.
Your code works as expected. For testing, put the variable into the invent