changed_when and $?

51 views
Skip to first unread message

Akos Vandra

unread,
Aug 24, 2014, 6:58:11 AM8/24/14
to ansible-project
Hello!

Is there a similar functionality to $? in many script languages in ansible?

I'd like to do something like this without having to register a
variable after all commandS:


- shell: <do something>
changed_when: $?.rc != 128

Regards,
Akos Vandra

Serge van Ginderachter

unread,
Aug 24, 2014, 7:20:52 AM8/24/14
to ansible...@googlegroups.com

On 24 August 2014 12:58, Akos Vandra <axo...@gmail.com> wrote:
- shell: <do something>
​      register: donesomething​
 
​      changed_when: donesomething.rc != 128​



Michael DeHaan

unread,
Aug 24, 2014, 9:59:34 AM8/24/14
to ansible...@googlegroups.com
"I'd like to do something like this without having to register a
variable after all commandS:"

Short answer, no.

We briefly had something like a "last_result" but this causes some wasted overhead to run all the time when something isn't being registered, and especially with fact caching support now a feature in the system, we don't want to hammer Redis like that if it were enabled.

So yes, you'll have to use register, but like Serge says, you can do it within the same task.





--
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 ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/CAEhzMJBOtmhZ%2BZkmCf7cUy5p2w8c6A7S1h7WYfqRG2PS-LetKg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages