tripleo-validations/roles/undercloud_disk_space/tasks/main.yml
Cédric Jeanneret ceb0f75182
Replace all references to the old role name
This change replaces all of the roles references in our various files with the
new role name. This is being done because Ansible no longer allows hyphens in
role names.

TODO: (gchamoul) Remove healthcheck-service-status once this patch is
merged. Tripleo Jobs are RED due to THT trying to execute this
validation as inflight one but it has been renamed healthcheck_service_status.

Co-Authored-by: Gael Chamoulaud <gchamoul@redhat.com>
Change-Id: I19bb587ece403f86ddd0bbe174c282326500cfd3
2020-01-23 17:25:43 +01:00

40 lines
1.1 KiB
YAML

---
- name: Set a constant defining number of Bytes in 1 GB
set_fact:
const_bytes_in_gb: 1073741824
- name: Stat volume directories
stat:
path: "{{ item.mount }}"
with_items: "{{ volumes }}"
register: volumes_stat
- 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.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 }}"