From afd45f8b79d89626dac68e829c4a6ab3a2a98e4d Mon Sep 17 00:00:00 2001 From: Pavel Cahyna Date: Wed, 16 Oct 2019 18:36:18 +0200 Subject: [PATCH] Assert that "get required packages" has not changed mounts It seems that the "get required packages" task (invocation of blivet with packages_only: true) silently (without even reporting changed: true) changes mounts. Add an assert for that. (It would be better to make it a separate unit test.) --- tasks/main-blivet.yml | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/tasks/main-blivet.yml b/tasks/main-blivet.yml index 061195c1..e7c18bb7 100644 --- a/tasks/main-blivet.yml +++ b/tasks/main-blivet.yml @@ -85,6 +85,15 @@ - debug: var: _storage_volumes +- name: load mount facts + setup: + gather_subset: '!all,!min,mounts' + register: __storage_mounts_before_packages + +# - name: show mounts before get required packages +# debug: +# var: __storage_mounts_before_packages + - name: get required packages blivet: pools: "{{ _storage_pools }}" @@ -94,6 +103,30 @@ packages_only: true register: package_info +- name: load mount facts + setup: + gather_subset: '!all,!min,mounts' + register: __storage_mounts_after_packages + +- name: detect mount alteration by 'get required packages' + block: + - name: show mounts before manage the pools and volumes + debug: + var: __storage_mounts_before_packages.ansible_facts.ansible_mounts + + - name: show mounts after manage the pools and volumes + debug: + var: __storage_mounts_after_packages.ansible_facts.ansible_mounts + + - name: fail if mounts changed + fail: + msg: "get required packages changed mounts. Changed status is + {{ package_info.changed }}" + when: + - __storage_mounts_before_packages.ansible_facts.ansible_mounts | + count != + __storage_mounts_after_packages.ansible_facts.ansible_mounts | count + - name: make sure required packages are installed package: name: "{{ package_info.packages }}"