[ansible-project] Ansible do-until loop in check mode

2017-06-27 Thread Ryan Groten
Using a standard do-until loop like this: > - shell: /bin/true > register: result > until: result.rc == 0 > retries: 5 > delay: 10 Anytime I run the playbook in check mode this task will fail (because the result variable is not set). It seems like the until part of

Re: [ansible-project] Ansible do-until loop in check mode

2017-06-27 Thread Kai Stian Olstad
On 27. juni 2017 19:19, Ryan Groten wrote: Using a standard do-until loop like this: - shell: /bin/true register: result until: result.rc == 0 retries: 5 delay: 10 Anytime I run the playbook in check mode this task will fail (because the result variable is no

Re: [ansible-project] Ansible do-until loop in check mode

2017-06-27 Thread Ryan Groten
Thanks for the response Kai, in this case I want the task not to run at all in check mode, only execute the loop when the play is run in execute mode. On Tuesday, 27 June 2017 11:26:06 UTC-6, Kai Stian Olstad wrote: > > On 27. juni 2017 19:19, Ryan Groten wrote: > > Using a standard do-until loo

Re: [ansible-project] Ansible do-until loop in check mode

2017-06-27 Thread Kai Stian Olstad
On 27. juni 2017 19:40, Ryan Groten wrote: Thanks for the response Kai, in this case I want the task not to run at all in check mode, only execute the loop when the play is run in execute mode. Than you can do this until: (result | default(0)).rc | default(0) == 0 -- Kai Stian Olstad -- You

Re: [ansible-project] Ansible do-until loop in check mode

2017-06-27 Thread Kai Stian Olstad
On 27. juni 2017 20:12, Kai Stian Olstad wrote: On 27. juni 2017 19:40, Ryan Groten wrote: Thanks for the response Kai, in this case I want the task not to run at all in check mode, only execute the loop when the play is run in execute mode. Than you can do this until: (result | default(0)).

Re: [ansible-project] Ansible do-until loop in check mode

2017-06-27 Thread Ryan Groten
That works just fine, thanks Kai! On Tuesday, 27 June 2017 12:17:03 UTC-6, Kai Stian Olstad wrote: > > On 27. juni 2017 20:12, Kai Stian Olstad wrote: > > On 27. juni 2017 19:40, Ryan Groten wrote: > >> Thanks for the response Kai, in this case I want the task not to run > >> at all > >> in ch

Re: [ansible-project] Ansible do-until loop in check mode

2017-06-27 Thread Ryan Groten
One slight wrinkle, my example wasn't exactly what I'm trying to do. Here's my real until loop: until: cluster_health.json.status | default("green") == "green" That fails with the error "'dict object' has no attribute 'json'" I think the difference is that my value is two attributes deep (ie:

Re: [ansible-project] Ansible do-until loop in check mode

2017-06-27 Thread Ryan Groten
Figured out a different solution. I added this conditional to my task: when: not ansible_check_mode Thanks for the help! On Tuesday, 27 June 2017 13:22:56 UTC-6, Ryan Groten wrote: > > One slight wrinkle, my example wasn't exactly what I'm trying to do. > Here's my real until loop: > > until: