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.
15 - name: Reread system properties
21 name: infra_deploy_vars
23 - name: Store total CPU, RAM, Disk requested resources
25 vcpu_t: "{{ item.vcpus|int + vcpu_t | int }}"
26 vram_t: "{{ item.ram|int + vram_t | int }}"
27 disk_t: "{{ item.disk|int + disk_t | int }}"
28 with_items: "{{ infra_deploy_vars.nodes }}"
30 - name: Fail if not enough RAM
32 msg: "Failed, not enough RAM, required: {{ vram_t }}, available {{ ansible_memory_mb.nocache.free }}"
33 when: ansible_memory_mb.nocache.free < vram_t | int
35 - name: Fail if not enough CPU
37 msg: "Failed, not enough CPU, required: {{ vcpu_t }}, available {{ ansible_processor_vcpus }}"
38 when: ansible_processor_vcpus < vcpu_t | int
40 - name: Define default network counter
42 num_default_network_detected: 0
44 - name: Increment counter for every default network detected
46 num_default_network_detected: "{{ num_default_network_detected | int + 1 }}"
48 - item.default_gateway is defined
49 - item.default_gateway == True
50 with_items: "{{ infra_deploy_vars.networks }}"
52 - name: Fail if more than 1 or 0 default networks
54 msg: "Failed, there must be 1 default network: {{ num_default_network_detected }} detected"
55 when: num_default_network_detected | int != 1
57 - name: Fail if not enough Disk space
59 disk_avail: "{% for mount in ansible_mounts if mount.mount == '/' %}{{ (mount.size_available/1024/1024) | int }}{% endfor %}"
61 msg: "Failed, not enough disk space, required {{ disk_t }}, available: {{ disk_avail }}"
62 when: disk_avail|int < disk_t | int
65 ostack_nodes: "{{ ostack_nodes | default([]) + [item.openstack_node] }}"
66 when: item.openstack_node is defined
67 with_items: "{{ infra_deploy_vars.nodes }}"
69 # all-in-one node node type must be controller, multinode requires at least one controller and one compute node
71 msg: "OpenStack node types currently supported: controller, compute. Check input VMs file."
72 when: ostack_nodes is undefined or ostack_nodes | length < 1
75 msg: "In all-in-one configuration OpenStack node type must be controller."
76 when: ostack_nodes | length == 1 and 'controller' not in ostack_nodes
79 msg: "At least one controller and one compute node expected when total number of OpenStack nodes is more than one."
80 when: ostack_nodes | length > 1 and not ('compute' in ostack_nodes and 'controller' in ostack_nodes)