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 the loop is evaluated even though the task is being skipped, what's the best way to fix this?
Kai Stian Olstad
unread,
Jun 27, 2017, 1:26:06 PM6/27/17
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to ansible...@googlegroups.com
To make shell and command module runs in check mode you need to add
check_mode: no
then the shell task will run inn check mode and the output is registered
in the variable.
--
Kai Stian Olstad
Ryan Groten
unread,
Jun 27, 2017, 1:40:05 PM6/27/17
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Ansible Project, ansible-pr...@olstad.com
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.
Kai Stian Olstad
unread,
Jun 27, 2017, 2:13:01 PM6/27/17
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to ansible...@googlegroups.com
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
Kai Stian Olstad
unread,
Jun 27, 2017, 2:17:03 PM6/27/17
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to ansible...@googlegroups.com
When I think about it, you don't need the first default because the
variable result do exist.
So the what you only need
until: result.rc | default(0) == 0
--
Kai Stian Olstad
Ryan Groten
unread,
Jun 27, 2017, 3:11:35 PM6/27/17
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Ansible Project, ansible-pr...@olstad.com
That works just fine, thanks Kai!
Ryan Groten
unread,
Jun 27, 2017, 3:22:56 PM6/27/17
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Ansible Project, ansible-pr...@olstad.com
One slight wrinkle, my example wasn't exactly what I'm trying to do. Here's my real until loop: