Initial commit
[ta/infra-ansible.git] / roles / performance_nodes_post / tasks / nova.yaml
1 ---
2
3 # Copyright 2019 Nokia
4
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
8 #
9 #     http://www.apache.org/licenses/LICENSE-2.0
10 #
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
16
17 - name: Set vcpu_pin_set
18   ini_file: dest=/etc/nova/nova.conf section=DEFAULT option=vcpu_pin_set value={{ ansible_local.ncir_cpu_allocation['vm']['list'] }} backup=no
19   register: nova1_result
20
21 - name: Get performance profile configuration
22   set_fact:
23     perf_profile: "{{ performance_profiles[hosts[hostname]['performance_profiles'][0]] if 'performance_profiles' in hosts[hostname] else {} }}"
24
25 - debug:
26     msg:
27       - "Hugepagesz: {{perf_profile['hugepagesz']}}"
28
29 - name: Construct reserved_huge_pages line for 1G case
30   set_fact:
31       numa0line: "reserved_huge_pages=node:0,size:1GB,count:4"
32       numa1line: "reserved_huge_pages=node:1,size:1GB,count:4"
33   when:
34     - perf_profile['hugepagesz'] == "1G"
35
36 - name: Construct reserved_huge_pages line for 2M case
37   set_fact:
38       numa0line: "reserved_huge_pages=node:0,size:2048,count:2048"
39       numa1line: "reserved_huge_pages=node:1,size:2048,count:2048"
40   when:
41     - perf_profile['hugepagesz'] == "2M"
42
43 - debug:
44     msg:
45       - "CPUs: {{ansible_processor_count}}"
46       - "NUMA0 conf: {{numa0line}}"
47       - "NUMA1 conf: {{numa1line}}"
48
49 - name: Set huge page reservation for NUMA 0
50   lineinfile:
51     path: /etc/nova/nova.conf
52     insertafter: 'DEFAULT'
53     line: "{{numa0line}}"
54   register: nova2_result
55
56 - name: Set huge page reservation for NUMA 1
57   lineinfile:
58     path: /etc/nova/nova.conf
59     insertafter: '{{numa0line}}'
60     line: "{{numa1line}}"
61   when:
62     - ansible_processor_count | int == 2
63   register: nova3_result
64
65 - name: Restart nova compute
66   systemd:
67     name: nova-compute
68     state: "restarted"
69   when:
70     - nova1_result.changed or nova2_result.changed or nova3_result.changed
71     - "'compute' in hosts[ansible_hostname]['service_profiles']"