Fix deprecation warning for undefined variables
Provide a default empty variable for 'bootstrap_host_data_disk_device'. Tasks which make use of this variable within with_items lists have been updated to evaluate that it has been set before executing. 'with_' clauses are evaluated before 'when' clauses. In Ansible 1.9 tasks are silently skipped when a variable within a 'with_' clause is undefined, Ansible 2 provides a deprecation warning. Change-Id: I66d7c15a43a70237b35d8ba7325d24e3b7206208
This commit is contained in:
parent
1fdfe7b3af
commit
58e9c8db6e
@ -70,7 +70,7 @@ bootstrap_host_bridge_storage_ports: none
|
||||
# be destroyed and repartitioned.
|
||||
#
|
||||
# Specify the secondary disk device to use.
|
||||
#bootstrap_host_data_disk_device: vdb
|
||||
bootstrap_host_data_disk_device: null
|
||||
#
|
||||
# Boolean value to force the repartitioning of the secondary device.
|
||||
bootstrap_host_data_disk_device_force: no
|
||||
|
@ -22,8 +22,7 @@
|
||||
- name: Identify the space available in /
|
||||
shell: |
|
||||
df -BK / | awk '/^[^Filesystem]/ {print $4}' | sed 's/K//'
|
||||
when:
|
||||
- bootstrap_host_data_disk_device is not defined
|
||||
when: bootstrap_host_data_disk_device == None
|
||||
changed_when: false
|
||||
register: root_space_available
|
||||
tags:
|
||||
@ -34,7 +33,7 @@
|
||||
set_fact:
|
||||
host_root_space_available_bytes: "{{ ( root_space_available.stdout | int) * 1024 | int }}"
|
||||
when:
|
||||
- bootstrap_host_data_disk_device is not defined
|
||||
- bootstrap_host_data_disk_device == None
|
||||
tags:
|
||||
- check-disk-size
|
||||
|
||||
@ -43,7 +42,7 @@
|
||||
host_data_disk_sectors: "{{ (ansible_devices[bootstrap_host_data_disk_device]['sectors'] | int) }}"
|
||||
host_data_disk_sectorsize: "{{ (ansible_devices[bootstrap_host_data_disk_device]['sectorsize'] | int) }}"
|
||||
when:
|
||||
- bootstrap_host_data_disk_device is defined
|
||||
- bootstrap_host_data_disk_device != None
|
||||
tags:
|
||||
- check-disk-size
|
||||
|
||||
@ -51,8 +50,7 @@
|
||||
- name: Calculate data disk size
|
||||
set_fact:
|
||||
host_data_disk_size_bytes: "{{ ((host_data_disk_sectors | int) * (host_data_disk_sectorsize | int)) | int }}"
|
||||
when:
|
||||
- bootstrap_host_data_disk_device is defined
|
||||
when: bootstrap_host_data_disk_device != None
|
||||
tags:
|
||||
- check-disk-size
|
||||
|
||||
@ -67,8 +65,7 @@
|
||||
assert:
|
||||
that: |
|
||||
(host_root_space_available_bytes | int) >= (host_data_disk_min_size_bytes | int)
|
||||
when:
|
||||
- bootstrap_host_data_disk_device is not defined
|
||||
when: bootstrap_host_data_disk_device == None
|
||||
tags:
|
||||
- check-disk-size
|
||||
|
||||
@ -76,8 +73,7 @@
|
||||
assert:
|
||||
that: |
|
||||
(host_data_disk_size_bytes | int) >= (host_data_disk_min_size_bytes | int)
|
||||
when:
|
||||
- bootstrap_host_data_disk_device is defined
|
||||
when: bootstrap_host_data_disk_device != None
|
||||
tags:
|
||||
- check-disk-size
|
||||
|
||||
|
@ -49,8 +49,7 @@
|
||||
|
||||
# Prepare the data disk, if one is provided
|
||||
- include: prepare_data_disk.yml
|
||||
when:
|
||||
- bootstrap_host_data_disk_device is defined
|
||||
when: bootstrap_host_data_disk_device != None
|
||||
tags:
|
||||
- prepare-data-disk
|
||||
|
||||
|
@ -55,8 +55,8 @@
|
||||
dev: "{{ item }}"
|
||||
when: data_disk_partitions.rc == 1 or bootstrap_host_data_disk_device_force | bool
|
||||
with_items:
|
||||
- "/dev/{{ bootstrap_host_data_disk_device }}1"
|
||||
- "/dev/{{ bootstrap_host_data_disk_device }}2"
|
||||
- "/dev/{{ bootstrap_host_data_disk_device }}1"
|
||||
- "/dev/{{ bootstrap_host_data_disk_device }}2"
|
||||
tags:
|
||||
- format-data-partitions
|
||||
|
||||
@ -67,7 +67,7 @@
|
||||
fstype: ext4
|
||||
state: mounted
|
||||
with_items:
|
||||
- { mount_point: /openstack, device: "/dev/{{ bootstrap_host_data_disk_device }}1"}
|
||||
- { mount_point: /var/lib/lxc, device: "/dev/{{ bootstrap_host_data_disk_device }}2"}
|
||||
- { mount_point: /openstack, device: "/dev/{{ bootstrap_host_data_disk_device }}1"}
|
||||
- { mount_point: /var/lib/lxc, device: "/dev/{{ bootstrap_host_data_disk_device }}2"}
|
||||
tags:
|
||||
- mount-data-partitions
|
||||
|
Loading…
Reference in New Issue
Block a user