Do not dereference .stdout if dmidecode is missing

In 459b2664d9 (Handle missing or bad
dmidecode) we accept return values of 0, 1 or 2 from command modules
that call 'dmidecode'.  However we then unconditionally look at the
stdout key in the result object.  When the dmidecode binary is missing
the result dictionary from the command module doesn't contain a stdout
key (resulting in something like):

---
fatal: [overcloud-novacomputeppc64le-1]: FAILED! => {"msg": "The task includes an option with an undefined variable. The error was: 'dict object' has no attribute 'stdout'\n\nThe error appears to have been in '/var/lib/mistral/overcloud/ceph-ansible/nodes_uuid_playbook.yml': line 14, column 7, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n      failed_when: machine_uuid.rc not in [0, 1, 2]\n    - name: generate host vars from nodes data\n      ^ here\n"}
---

This change just adds a default('') filter to the lookup so a missing
key will fallback to an empty dictionary

Closes-Bug: 1790447
Change-Id: I7db180674c3696508a7f449e2e825e7083a00f6e
This commit is contained in:
Tony Breeds 2019-01-08 20:58:21 +11:00
parent 941cf073c7
commit f9b5401c1f
1 changed files with 1 additions and 1 deletions

View File

@ -443,7 +443,7 @@ outputs:
- name: generate host vars from nodes data
local_action:
module: copy
content: "{% raw %}{{nodes_data[machine_uuid.stdout]|default({})|to_nice_yaml}}{% endraw %}"
content: "{% raw %}{{nodes_data[machine_uuid.stdout|default('')]|default({})|to_nice_yaml}}{% endraw %}"
dest: "{{playbook_dir}}/ceph-ansible/host_vars/{% raw %}{{inventory_hostname}}{% endraw %}.yml"
- name: ceph_base_external_deploy_task
when: step == '2'