1 # Copyright (c) 2018 Intel Corporation.
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
7 # http://www.apache.org/licenses/LICENSE-2.0
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
18 name: infra_deploy_vars
20 - name: Store total CPU, RAM, Disk requested resources
22 vcpu_t: "{{item.vcpus|int + vcpu_t|int}}"
23 vram_t: "{{item.ram|int + vram_t|int}}"
24 disk_t: "{{item.disk|int + disk_t|int}}"
25 with_items: "{{infra_deploy_vars.nodes}}"
27 - name: Fail if not enough RAM
29 msg: "Failed, not enough RAM, required: {{ vram_t }}, available {{ ansible_memory_mb.nocache.free }}"
30 when: ansible_memory_mb.nocache.free < vram_t|int
32 - name: Fail if not enough CPU
34 msg: "Failed, not enough CPU, required: {{ vcpu_t }}, available {{ ansible_processor_vcpus }}"
35 when: ansible_processor_vcpus < vcpu_t|int
38 - name: Fail if not enough Disk space
40 disk_avail: "{% for mount in ansible_mounts if mount.mount == '/' %}{{ (mount.size_available/1024/1024)|int }}{% endfor %}"
42 msg: "Failed, not enough disk space, required {{ disk_t }}, available: {{ disk_avail }}"
43 when: disk_avail|int < disk_t|int