Fix disk space validation

Due to the containerization, looking into ansible_facts to
obtain results about mounts is not working. We will use simple
df to loop on needed volumes instead.

This change also fixes the old outdate documentation links in
both undercloud-disk-space and undercloud-disk-space-pre-upgrade
validations.

Change-Id: I5c7b2558b55e45d6f7c15d41e558825cabe0b130
This commit is contained in:
Ana Krivokapic 2018-11-06 19:00:14 +01:00
parent b1f18c7a2e
commit 8834a4a1ab
3 changed files with 36 additions and 17 deletions

View File

@ -2,15 +2,35 @@
set_fact:
const_bytes_in_gb: 1073741824
- name: filter out directories that are not a mount path
set_fact:
mounted_dirs: "{{ a_mounts |map(attribute='mount') | intersect(volumes|map(attribute='mount')|list)}}"
- name: Stat volume directories
stat:
path: "{{ item.mount }}"
with_items: "{{ volumes }}"
register: volumes_stat
- name: loop on existing volumes, check available space
fail:
msg: "Minimum required for {{ item.mount }}: {{ volumes | selectattr('mount', 'equalto', item.mount) | map(attribute='min_size') | list | join('') }}G - volume free space: {{ (item.size_available|int / const_bytes_in_gb|int) |round(1) }}G"
failed_when: "(volumes | selectattr('mount', 'equalto', item.mount) | map(attribute='min_size') | list | join('')|int) > (item.size_available|int / const_bytes_in_gb|int) |int"
loop: "{{ a_mounts }}"
- name: Initialize existing_volumes to an empty array
set_fact:
existing_volumes="{{ [] }}"
- name: Filter out non-existing volumes
set_fact:
existing_volumes: "{{ existing_volumes +[item.item] }}"
with_items: "{{ volumes_stat.results }}"
when: item.stat.exists
loop_control:
label: "{{ item.mount }}"
when: "item.mount in mounted_dirs"
label: "{{ item.item.mount }}"
- name: Loop on volumes and gather available space
shell: df -B1 {{ item.mount }} --output=avail | sed 1d
register: volume_size
with_items: "{{ existing_volumes }}"
changed_when: False
- name: Fail if any of the volumes are too small
fail:
msg: "Minimum free space required for {{ item.item.mount }}: {{ item.item.min_size }}G - current free space: {{ (item.stdout|int / const_bytes_in_gb|int) |round(1) }}G"
when: >
item.stdout|int / const_bytes_in_gb|int < item.item.min_size|int
with_items: "{{ volume_size.results }}"
loop_control:
label: "{{ item.item.mount }}"

View File

@ -4,10 +4,10 @@
metadata:
name: Verify undercloud fits the disk space requirements to perform an upgrade
description: >
Make sure that the root partition on the undercloud node is large
enough before starting an upgrade
Make sure that the root partition on the undercloud node has enough
free space before starting an upgrade
http://tripleo.org/environments/environments.html#id5
http://tripleo.org/install/environments/baremetal.html#minimum-system-requirements
groups:
- pre-upgrade
volumes:
@ -15,7 +15,6 @@
- {mount: /var/lib/config-data, min_size: 3}
- {mount: /var, min_size: 16}
- {mount: /, min_size: 20}
a_mounts: "{{hostvars[inventory_hostname].ansible_facts.mounts}}"
tasks:
- include_tasks: tasks/disk_space.yaml

View File

@ -4,9 +4,10 @@
metadata:
name: Verify undercloud fits the disk space requirements
description: >
Make sure that the root partition on the undercloud node is large enough.
Make sure that the root partition on the undercloud node has enough
free space.
http://tripleo.org/environments/environments.html#id5
http://tripleo.org/install/environments/baremetal.html#minimum-system-requirements
groups:
- prep
- pre-introspection
@ -17,7 +18,6 @@
- {mount: /usr, min_size: 5}
- {mount: /var, min_size: 20}
- {mount: /, min_size: 25}
a_mounts: "{{hostvars[inventory_hostname].ansible_facts.mounts}}"
tasks:
- include_tasks: tasks/disk_space.yaml