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
37 - name: Define default network counter
39 num_default_network_detected: 0
41 - name: Increment counter for every default network detected
43 num_default_network_detected: "{{ num_default_network_detected|int + 1 }}"
45 - item.default_gateway is defined
46 - item.default_gateway == True
47 with_items: "{{infra_deploy_vars.networks}}"
49 - name: Fail if more than 1 or 0 default networks
51 msg: "Failed, there must be 1 default network: {{ num_default_network_detected }} detected"
52 when: num_default_network_detected|int != 1
54 - name: Fail if not enough Disk space
56 disk_avail: "{% for mount in ansible_mounts if mount.mount == '/' %}{{ (mount.size_available/1024/1024)|int }}{% endfor %}"
58 msg: "Failed, not enough disk space, required {{ disk_t }}, available: {{ disk_avail }}"
59 when: disk_avail|int < disk_t|int