From f933d7f02f7c10b441d6b59c502b5d63113e1e4c Mon Sep 17 00:00:00 2001 From: Masayoshi Mizuma Date: Sun, 3 Jul 2022 18:07:27 +0900 Subject: [PATCH] Fix to check the result of undercloud_debug validation undercloud_debug validation always fails because the playbook doesn't check config_result correctly. The structure of config_result is like as follows: "changed": false, "msg": "All items completed", "results": [ { "ansible_loop_var": "item", "changed": false, "failed": false, "invocation": { "module_args": { "default": null, "ignore_missing_file": true, "key": "debug", "path": "/var/lib/config-data/puppet-generated/neutron/etc/neutron/neutron.conf", "section": "DEFAULT" } }, "item": "/var/lib/config-data/puppet-generated/neutron/etc/neutron/neutron.conf", "msg": "The key 'debug' under the section 'DEFAULT' in file /var/lib/config-data/puppet-generated/neutron/etc/neutron/neutron.conf has the value: 'True'", "value": "True" }, ... Fix the playbook to see confi_result structure correctly. Change-Id: I8fb6167f62ae7252f6f57249a30b74f5679115d3 --- roles/undercloud_debug/molecule/default/converge.yml | 4 +++- roles/undercloud_debug/tasks/main.yml | 10 ++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/roles/undercloud_debug/molecule/default/converge.yml b/roles/undercloud_debug/molecule/default/converge.yml index cca7f2ea7..67ada326f 100644 --- a/roles/undercloud_debug/molecule/default/converge.yml +++ b/roles/undercloud_debug/molecule/default/converge.yml @@ -35,12 +35,14 @@ include_role: name: undercloud_debug vars: - debug_check: false + debug_check: true - name: Should fail due to bad value block: - include_role: name: undercloud_debug + vars: + debug_check: false rescue: - name: Clear host errors diff --git a/roles/undercloud_debug/tasks/main.yml b/roles/undercloud_debug/tasks/main.yml index b845174e1..69d884475 100644 --- a/roles/undercloud_debug/tasks/main.yml +++ b/roles/undercloud_debug/tasks/main.yml @@ -1,5 +1,5 @@ --- -- name: Check the services for debug flag +- name: Get the services for debug flag become: true validations_read_ini: path: "{{ item }}" @@ -8,4 +8,10 @@ ignore_missing_file: true register: config_result with_items: "{{ services_conf_files }}" - failed_when: "debug_check|bool == config_result.value|bool" + +- name: Check the services for debug flag + fail: + msg: > + debug_check is set to {{ debug_check }} and the result of + validation is {{ config_result.results[0].value }} + failed_when: "debug_check|bool != config_result.results[0].value|bool"