add yardstick iruya 9.0.0 release notes
[yardstick.git] / ansible / roles / infra_check_requirements / tasks / main.yml
1 # Copyright (c) 2018 Intel Corporation.
2 #
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
6 #
7 #      http://www.apache.org/licenses/LICENSE-2.0
8 #
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.
14 ---
15 - name: Reread system properties
16   setup:
17
18 - name: Include
19   include_vars:
20     file: "{{ rs_file }}"
21     name: infra_deploy_vars
22
23 - name: Store total CPU, RAM, Disk requested resources
24   set_fact:
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 }}"
29
30 - name: Fail if not enough RAM
31   fail:
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
34
35 - name: Fail if not enough CPU
36   fail:
37     msg: "Failed, not enough CPU, required: {{ vcpu_t }}, available {{ ansible_processor_vcpus }}"
38   when: ansible_processor_vcpus < vcpu_t | int
39
40 - name: Define default network counter
41   set_fact:
42     num_default_network_detected: 0
43
44 - name: Increment counter for every default network detected
45   set_fact:
46     num_default_network_detected: "{{ num_default_network_detected | int + 1 }}"
47   when:
48     - item.default_gateway is defined
49     - item.default_gateway == True
50   with_items: "{{ infra_deploy_vars.networks }}"
51
52 - name: Fail if more than 1 or 0 default networks
53   fail:
54     msg: "Failed, there must be 1 default network: {{ num_default_network_detected }} detected"
55   when: num_default_network_detected | int != 1
56
57 - name: Fail if not enough Disk space
58   set_fact:
59     disk_avail: "{% for mount in ansible_mounts if mount.mount == '/' %}{{ (mount.size_available/1024/1024) | int }}{% endfor %}"
60 - fail:
61     msg: "Failed, not enough disk space, required {{ disk_t }}, available: {{ disk_avail }}"
62   when: disk_avail|int < disk_t | int
63
64 - set_fact:
65     ostack_nodes: "{{ ostack_nodes | default([]) + [item.openstack_node] }}"
66   when: item.openstack_node is defined
67   with_items: "{{ infra_deploy_vars.nodes }}"
68
69 # all-in-one node node type must be controller, multinode requires at least one controller and one compute node
70 - fail:
71     msg: "OpenStack node types currently supported: controller, compute. Check input VMs file."
72   when: ostack_nodes is undefined or ostack_nodes | length < 1
73
74 - fail:
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
77
78 - fail:
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)