[ansible-project] need help with if condition in jinja template

2023-02-26 Thread Kenady Inampudi
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

Re: [ansible-project] need help with if condition in jinja template

2023-02-26 Thread Dick Visser
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. > >

Re: [ansible-project] need help with if condition in jinja template

2023-02-26 Thread Kenady Inampudi
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] ***

[ansible-project] Re: need help with if condition in jinja template

2023-02-26 Thread Todd Lewis
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

[ansible-project] Re: need help with if condition in jinja template

2023-02-26 Thread Kenady Inampudi
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

Re: [ansible-project] Re: need help with if condition in jinja template

2023-02-26 Thread Vladimir Botka
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