Skip to content

Commit

Permalink
Assert that "get required packages" has not changed mounts
Browse files Browse the repository at this point in the history
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.)
  • Loading branch information
pcahyna committed Jun 10, 2020
1 parent 1e4558d commit fe6fc11
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions tasks/main-blivet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,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 }}"
Expand All @@ -96,6 +105,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 }}"
Expand Down

0 comments on commit fe6fc11

Please sign in to comment.