-
Notifications
You must be signed in to change notification settings - Fork 0
/
validate_hypervisor.yml
25 lines (23 loc) · 1.11 KB
/
validate_hypervisor.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
---
- name: Validate hypervisor
hosts: hypervisor
gather_facts: yes
any_errors_fatal: true
vars:
memory_buffer: 1.2
tasks:
- name: calculate needed memory
include_tasks: tasks/calc_needed_memory.yml
with_dict: "{{ provision.topology.nodes }}"
loop_control:
loop_var: node
- debug:
msg: "Current free memory is {{ ansible_memory_mb.nocache.free }}MB. The required memory for the topology is {{ nodes_memory }}MB and it is more than free memory, but it is under the buffer of 20%."
when:
- nodes_memory|int > ansible_memory_mb.nocache.free|int
- nodes_memory|int <= ansible_memory_mb.nocache.free|int * memory_buffer|float
- fail:
msg: "Not enough memory on Hypervisor. Current free memory is {{ ansible_memory_mb.nocache.free }}MB, required is {{ nodes_memory }}MB. Use `--host-memory-overcommit True` if you want to overcommit memory usage"
when:
- nodes_memory|int > ansible_memory_mb.nocache.free|int * memory_buffer|float
- not provision.host.memory.overcommit|default('False')