diff --git a/validations/tasks/disk_space.yaml b/validations/tasks/disk_space.yaml index 3d7845e7f..842bef392 100644 --- a/validations/tasks/disk_space.yaml +++ b/validations/tasks/disk_space.yaml @@ -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 }}" diff --git a/validations/undercloud-disk-space-pre-upgrade.yaml b/validations/undercloud-disk-space-pre-upgrade.yaml index 7e115a638..78ffdf259 100644 --- a/validations/undercloud-disk-space-pre-upgrade.yaml +++ b/validations/undercloud-disk-space-pre-upgrade.yaml @@ -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 diff --git a/validations/undercloud-disk-space.yaml b/validations/undercloud-disk-space.yaml index bea352484..32834a1ef 100644 --- a/validations/undercloud-disk-space.yaml +++ b/validations/undercloud-disk-space.yaml @@ -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