
This is an initial commit towards doing a pre-flight check for disk space using roles in Ansible. Currently the check is pretty simple but we could make it more complex. Change-Id: I16182e5a42b8d65d8da9291df265480cc7e57c54
23 lines
1.3 KiB
YAML
23 lines
1.3 KiB
YAML
# Copyright (c) 2014 Hewlett-Packard Development Company, L.P.
|
|
#
|
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
# you may not use this file except in compliance with the License.
|
|
# You may obtain a copy of the License at
|
|
#
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
#
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
# implied.
|
|
# See the License for the specific language governing permissions and
|
|
# limitations under the License.
|
|
---
|
|
- name: Check if free disk percentage is too low
|
|
fail: msg="ERROR - {{ item.size_available|filesizeformat }} is not enough (need at least {{ fail_percent }}% free)"
|
|
with_items: "hostvars[inventory_hostname].ansible_mounts"
|
|
when: item.mount not in exclude_mounts and fail_percent is defined and "{{ ((item.size_available / item.size_total) * 100)|round|int }}"|int < fail_percent
|
|
- name: Check if free disk size is too low
|
|
fail: msg="ERROR - {{ item.size_available|filesizeformat }} is not enough (need at least {{ fail_size }} free)"
|
|
with_items: "hostvars[inventory_hostname].ansible_mounts"
|
|
when: item.mount not in exclude_mounts and fail_size is defined and "{{ item.size_available }}"|int < fail_size |