Skip to content

Commit 5096bf8

Browse files
committed
Check whether pool variable is defined to relevant conditionals when storage_pools is undefined.
Previously, if the playbook was run with just storage_volumes defined then various installation and mount tasks would fail in fs-default.yml and mount-default.yml, respectively.
1 parent a6e33c4 commit 5096bf8

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

tasks/fs-default.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
register: xfsprogs_installed
1010
when: "volume.fs_type == 'xfs' and ['xfsprogs'] is not subset(ansible_facts.packages.keys()) \
1111
and xfsprogs_installed is undefined and not ansible_check_mode \
12-
and (pool.state in 'present' and volume.state in 'present')"
12+
and ((pool is defined and pool.state in 'present') or volume.state in 'present')"
1313

1414
- name: Install e2fsprogs for ext file system type
1515
package:
@@ -19,16 +19,16 @@
1919
when: "volume.fs_type in ['ext2', 'ext3', 'ext4'] and \
2020
['e2fsprogs'] is not subset(ansible_facts.packages.keys()) and \
2121
e2fsprogs_installed is undefined and not ansible_check_mode \
22-
and (pool.state in 'present' and volume.state in 'present')"
22+
and ((pool is defined and pool.state in 'present') or volume.state in 'present')"
2323

2424
- name: Install util-linux as needed
2525
package:
2626
name: util-linux
2727
state: present
2828
register: util_linux_installed
29-
when: "(volume.fs_type == 'swap' or volume.state == 'absent' or \
30-
(pool.state is defined and pool.state == 'absent')) and \
31-
['util-linux'] is not subset(ansible_facts.packages.keys()) and \
29+
when: "(volume.fs_type == 'swap' or volume.state == 'absent' or
30+
(pool is defined and pool.state is defined and pool.state == 'absent'))
31+
and ['util-linux'] is not subset(ansible_facts.packages.keys()) and
3232
util_linux_installed is undefined and not ansible_check_mode"
3333

3434
- name: unmount fs if we're going to reformat

tasks/mount-default.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
- name: configure mount state (2/2)
3030
set_fact:
3131
mount_state: "{{ pool.state }}"
32-
when: pool.state is defined and pool.state == "absent"
32+
when: pool is defined and pool.state is defined and pool.state == "absent"
3333

3434
# Set up the mount using a stable device identifier.
3535
- name: Set up the mount

0 commit comments

Comments
 (0)