Hello,
I’m trying to run a command based on the result of a ‘yum update’ command on a Linux system. The idea being that if there are no patches, then I want to create a file that will be checked for just prior to a reboot. If the file exists, then no reboot, if the file doesn’t exist, reboot since yum update actually updated packages. Below is my current playbook, minus the reboot portion as I’m just in the testing phase.
I don’t get any errors, but my conditional statement isn’t seeing the string ‘Nothing to do’ and I know that is in the output of the yum update attempt.
Anyone have any ideas?
Thanks,
Of course the other option is to create the file if the value of update_status.changed and update_status.failed are both false, meaning nothing changed, but it didn’t fail. Either way, still can’t get it to see that those values are both ‘false’
–code
- name: create no_patch file
command: touch /tmp/no_patch
args:
creates: /tmp/no_patch
when:
- update_status.changed == “false,”
- update_status.failed == “false,”
–output
ok: [entrhelx01.oshkoshglobal.com] => {
“msg”: {
“changed”: false,
“failed”: false,
“msg”: " Warning: Due to potential bad behaviour with rhnplugin and certificates, used slower repoquery calls instead of Yum API.",
“rc”: 0,
“results”: [
“Nothing to do here, all packages are up to date”
]
}
Figured it out. the code should look like the following: