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
register: donesomething
changed_when: donesomething.rc != 128
“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.