Add pod.yaml files for Apex
[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: Include
16   include_vars:
17     file: "{{rs_file}}"
18     name: infra_deploy_vars
19
20 - name: Store total CPU, RAM, Disk requested resources
21   set_fact:
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}}"
26
27 - name: Fail if not enough RAM
28   fail:
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
31
32 - name: Fail if not enough CPU
33   fail:
34     msg: "Failed, not enough CPU, required: {{ vcpu_t }}, available {{ ansible_processor_vcpus }}"
35   when: ansible_processor_vcpus < vcpu_t|int
36
37 - name: Define default network counter
38   set_fact:
39     num_default_network_detected: 0
40
41 - name: Increment counter for every default network detected
42   set_fact:
43     num_default_network_detected: "{{ num_default_network_detected|int + 1 }}"
44   when:
45     - item.default_gateway is defined
46     - item.default_gateway == True
47   with_items: "{{infra_deploy_vars.networks}}"
48
49 - name: Fail if more than 1 or 0 default networks
50   fail:
51     msg: "Failed, there must be 1 default network: {{ num_default_network_detected }} detected"
52   when: num_default_network_detected|int != 1
53
54 - name: Fail if not enough Disk space
55   set_fact:
56     disk_avail: "{% for mount in ansible_mounts if mount.mount == '/' %}{{ (mount.size_available/1024/1024)|int }}{% endfor %}"
57 - fail:
58     msg: "Failed, not enough disk space, required {{ disk_t }}, available: {{ disk_avail }}"
59   when: disk_avail|int < disk_t|int