File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1414 use : " {{ (__snapshot_is_ostree | d(false)) |
1515 ternary('ansible.posix.rhel_rpm_ostree', omit) }}"
1616
17- - name : Get snapm version
18- check_mode : false
19- command : snapm --version
20- changed_when : false
21- register : __snapshot_snapm_version_output
22- # Ignore errors as snapm may not be available
23- ignore_errors : true
17+ - name : Get package facts
18+ package_facts :
19+ no_log : " {{ ansible_verbosity < 2 }}"
2420
25- - name : Set snapm availability fact
21+ - name : Set snapm availability fact and version
2622 set_fact :
27- __snapshot_snapm_available : " {{ __snapshot_snapm_version_output is success }}"
28-
29- - name : Set snapm version
30- set_fact :
31- __snapshot_snapm_version : " {{ __snapshot_snapm_version_output.stdout }}"
32- when : __snapshot_snapm_available
23+ __snapshot_snapm_available : " {{ 'snapm' in ansible_facts.packages }}"
24+ __snapshot_snapm_version : " {{ ansible_facts.packages.get('snapm', [{}])[0].get('version', '0.0') }}"
3325
3426# Determine if bootable support is needed
3527# If snapshot_lvm_bootable is set to true, or any of the volumes in snapshot_lvm_set
Original file line number Diff line number Diff line change 129129 assert :
130130 that : not snapshot_cmd["changed"]
131131
132+ rescue :
133+ - name : Do not fail if snapm is too old for test
134+ assert :
135+ that : ansible_failed_result.msg is search(msg1) or ansible_failed_result.msg is search(msg2)
136+ vars :
137+ msg1 : " Package snapm version .* is too old"
138+ msg2 : " Package snapm version 0.5 or later is required to use bootable snapsets"
139+
132140 always :
133141 - name : Cleanup
134142 include_tasks : tasks/cleanup.yml
Original file line number Diff line number Diff line change 9999 assert :
100100 that : not snapshot_cmd["changed"]
101101 rescue :
102- - name : Check if error is due to snapm version too old
103- fail :
104- msg : Unexpected error occurred {{ ansible_failed_result | to_nice_json }}
105- when : not ansible_failed_result.msg is search(err_msg)
102+ - name : Do not fail if snapm is too old for test
103+ assert :
104+ that : ansible_failed_result.msg is search(msg1) or ansible_failed_result.msg is search(msg2)
106105 vars :
107- err_msg : Package snapm .*version 0.5 or later is required to use bootable snapsets
106+ msg1 : " Package snapm version .* is too old"
107+ msg2 : " Package snapm version 0.5 or later is required to use bootable snapsets"
108108 always :
109109 - name : Cleanup
110110 include_tasks : tasks/cleanup.yml
You can’t perform that action at this time.
0 commit comments