On Saturday, 24 March 2018 10.45.29 CET Trond Hindenes wrote: > I have the following steps in a playbook: > - name: check if .net 4.7.1 is installed > script: check_net_version.ps1 "4.7.1" > register: net471result > changed_when: false > > - name: Install .Net 4.7.1 > win_chocolatey: > name: dotnet4.7.1 > register: net471_exit_code > failed_when: net471_exit_code.rc != 0 and net471_exit_code.rc != 3010 > when: '"missing" in net471result.stdout' > > - name: reboot node if needed > win_reboot: > when: net471_exit_code.rc is defined and net471_exit_code.rc == 3010 and > allow_reboot is defined and (allow_reboot | bool) > > > > > Check if software is missing (using a custom script because some > weirdness), install if it is. > This has worked fine for us in Ansible 2.3.x which we've been on until now, > but this fails in 2.5.0. Even if I add a check for making sure the > "net471_exit_code" var exists altogether, it fails: > > "msg": "The conditional check 'net471_exit_code.rc != 0 and > net471_exit_code.rc != 3010' failed. The error was: error while evaluating > conditional (net471_exit_code.rc != 0 and net471_exit_code.rc != 3010): > 'dict object' has no attribute 'rc'" > > It seems to me that there's some bug in how Ansible evaluates object > attributes (or dict keys), so that "net471_exit_code.rc is defined" is > picked up as a "true" instead of a "false". > > Anyone able to repro?
I think this is because win_chocolatey doesn't return rc anymore so maybe the bug lies there. You could check by run win_chocolatey register and print the result. I can reproduce this by replacing win_chocolatey with debug that does not return rc. But if I use command module that do return rc it works. -- Kai Stian Olstad -- 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/2413277.CxNNdz6Zqy%40x1. For more options, visit https://groups.google.com/d/optout.
