Hey all,
take a look at this and lemme know where I’m hosed at. The errors are a bit misleading:
Hey all,
take a look at this and lemme know where I’m hosed at. The errors are a bit misleading:
The ‘check if reboot is required’ tasks were both skipped, resulting in ‘reboot_required’ not being defined.
Yes. One simple cure would be to do an initial set_fact to set reboot_required to false, so that even if neither of the skipped tasks sets it, the variable is there to be checked.
A second simple cure would be to set it to false after the the other tests, conditional upon it not already being defined, so:
or
BTW both of those are off the top of my head so probably syntactically wrong but you get the idea
A slightly less simple cure would be to check whether it is defined as part of the test of its value. much as you have done with stdout length. I think is be less obvious to the reader.
when: reboot_required is defined and reboot_required == false
… again, I probably have the syntax wrong.
All of this presupposes that instead of directly checking components of a structured return value, you turn your various tests into a simple boolean as a separate operation; then afterwards you can use a much more readable “when: reboot_required”. So in the stanzas where you have a structured value and are looking for a string in it, you would call the structured value something else, and generate reboot_required from it. Just a thought.
Regards, K.