I’m using the zypper and apt modules to update remote hosts. I don’t know if I’m missing something or it’s a bug, but registering a variable in the zypper module is getting skipped. It works fine in the apt module.
You are registering to the same variable in both tasks. Ansible will register regardless of the task being skipped or not.
If the suse/zypper task executes, I assume that the apt task should skip, as such, the zypper task registered with real data first, and then the apt task overwrites the result with a skipped info.
You should be using different register variable names for each task, to avoid this issue.
But the zypper module returns completely different parameters than the apt module. Shouldn’t it contain stdout and stderr too? I’ve tried removing all the apt stuff to eliminate any conflicts but the results didn’t change. This is the zypper_result variable dump. It runs zypper update just fine on the host but I’m not getting the return values I want. At minimum I need the stdout and stderr output.
the ansible zypper module calls zypper with --quiet, as you can check on
the commandline that leads to zypper not writing to stdout, if there's
nothing to do:
Thanks, I thought that might be it. Seems pointless to suppress all the output. I used the “command” module instead with all the same parameters except --quiet and --xmlout and it’s working fine. And since I can’t use the “changed” parameter with command to see if any packages were updated (it always seems to return true), I’m instead checking its stdout for the string “Nothing to do”.