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. On Thu, Jun 13, 2019 at 11:23 AM Bobby Hood <[email protected]> wrote: > 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. > > - name: (SuSE) Update all packages to latest versions > when: ansible_os_family == "Suse" > *zy*pper: > name: '*' > state: latest > type: package > update_cache: yes > register: update_result > - name: (Debian) Update all packages to latest versions > when: ansible_os_family == "Debian" > apt: > name: '*' > state: latest > update_cache: yes > force_apt_get: yes > autoremove: yes > register: update_result > > > > This is the variable dump when using zypper. It's always *"changed": > false* and *"skipped": true* even if changes are made. > > ok: [raamah] => { > "update_result": { > "changed": false, > "skip_reason": "Conditional result was False", > "skipped": true > } > } > > > However, the apt module always returns values for "msg", "stderr", and > "stdout" as seen below. Am I using the zypper module incorrectly or > something? > > ok: [webtest01] => { > "update_result": { > "changed": false, > "failed": false, > "msg": "Reading package lists...\nBuilding dependency > tree...\nReading state information...\nCalculating upgrade...\n0 upgraded, > 0 newly installed, 0 to remove and 0 not upgraded.\n", > > "stderr": "", > "stderr_lines": [], > "stdout": "Reading package lists...\nBuilding dependency > tree...\nReading state information...\nCalculating upgrade...\n0 upgraded, > 0 newly installed, 0 to remove and 0 not upgraded.\n", > > "stdout_lines": [ > "Reading package lists...", > "Building dependency tree...", > "Reading state information...", > "Calculating upgrade...", > "0 upgraded, 0 newly installed, 0 to remove and 0 not > upgraded." > ] > } > } > > This e-mail message (including any attachments) is for the sole use of the > intended recipient(s) and may contain confidential, privileged, and/or > proprietary information. If the reader of this message is not the intended > recipient, you are hereby notified that any dissemination, distribution or > copying of this message (including any attachments) is strictly prohibited. > > If you have received this message in error, please contact the sender by > reply e-mail message and destroy all copies of the original message > (including attachments). > > -- > 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 [email protected]. > To post to this group, send email to [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/ansible-project/6029dc73-1bdb-4623-92d4-a59801c9f029%40googlegroups.com > <https://groups.google.com/d/msgid/ansible-project/6029dc73-1bdb-4623-92d4-a59801c9f029%40googlegroups.com?utm_medium=email&utm_source=footer> > . > For more options, visit https://groups.google.com/d/optout. > -- Matt Martz @sivel sivel.net -- 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 [email protected]. To post to this group, send email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/CAD8N0v9rKzs2BCrwN2nBJVBq0Y3c0CcER7em-x3yNm2tHPTjVw%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
