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
9 # http://www.apache.org/licenses/LICENSE-2.0
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.
18 - name: Get configuration.
20 perf_profile: "{{ performance_profiles[hosts[hostname]['performance_profiles'][0]] if 'performance_profiles' in hosts[hostname] else {} }}"
21 cpu_alloc: "{{ ansible_local.cpu_allocation | default([]) }}"
27 - name: Get tuning option.
29 tuning: "{{ perf_profile['tuning'] | default('standard') }}"
33 - name: Make combined CPU lists.
35 cpu_alloc: "{{ cpu_alloc | cpulist_combine(item['name'], item['lists']) }}"
37 - { 'name': 'app', 'lists': ['ovs_dpdk', 'vm'] }
39 - name: Make sure configuration directory exists.
41 path: /etc/systemd/system.conf.d
45 - name: Set platform CPU affinity.
47 dest: /etc/systemd/system.conf.d/00affinity.conf
51 value: "{{ cpu_alloc['platform']['set'] | join(' ') }}"
53 register: platform_affinity
54 when: cpu_alloc | length > 0
56 - name: Make CPU list parameters.
58 kcmdline_default_list: "{{ kcmdline_default_list + [ item['opt'] + '=' + cpu_alloc[item['list']]['list'] ] }}"
60 - { 'opt': 'irqaffinity', 'list': 'platform' }
61 - { 'opt': 'kthread', 'list': 'platform' }
62 - { 'opt': 'nohz_full', 'list': 'app' }
63 - { 'opt': 'rcu_nocbs', 'list': 'app' }
64 - { 'opt': 'isolcpus', 'list': 'ovs_dpdk' }
65 when: "item['list'] in cpu_alloc"
67 - name: Make low latency kernel cmdline parameters.
69 kcmdline_default_list: "{{ kcmdline_default_list + perf_profile['low_latency_options'] | default([]) }}"
71 - "tuning == 'low_latency'"
73 - name: Make hugepage parameters.
75 kcmdline_default_list: "{{ kcmdline_default_list + [ item + '=' + perf_profile[item] | string ] }}"
76 with_items: ['default_hugepagesz', 'hugepagesz', 'hugepages']
77 when: item in perf_profile
82 - name: Set common kernel parameters.
84 name: /etc/default/grub
85 regexp: "^GRUB_CMDLINE_LINUX="
86 line: "GRUB_CMDLINE_LINUX='{{ kcmdline_list | list_to_cmdline }}'"
87 register: grub_cmdline
90 var: kcmdline_default_list
92 - name: Set default kernel parameters.
94 name: /etc/default/grub
95 regexp: "^GRUB_CMDLINE_LINUX_DEFAULT="
96 line: "GRUB_CMDLINE_LINUX_DEFAULT='{{ kcmdline_default_list | list_to_cmdline }}'"
97 register: grub_cmdline_default
99 - name: Generate grub configurations
100 command: grub2-mkconfig -o /boot/grub2/grub.cfg
101 when: grub_cmdline.changed or grub_cmdline_default.changed
103 - name: Ensure network.service is enabled
108 - name: Set reboot command
110 reboot_cmd: "( sleep 3 && /sbin/reboot & )"
113 shell: "{{ reboot_cmd }}"
117 register: reboot_node
119 - grub_cmdline.changed or grub_cmdline_default.changed or platform_affinity.changed
120 - hostname != installation_controller
121 - installation_phase != "postconfig-ended" or (scaled_out_nodes is defined and hostname in scaled_out_nodes) or (reinitialized_nodes is defined and hostname in reinitialized_nodes)
123 - name: Wait for the server to reboot
125 host: "{{ansible_host}}"
128 search_regex: OpenSSH
132 register: remote_success
133 until: remote_success is succeeded
135 when: reboot_node is changed
137 - name: Wait for remote node ssh login. Wating for 10mins max.
138 become: "{{ ansible_env.SUDO_USER }}"
139 local_action: shell ssh -oBatchMode=yes -4 -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null {{ ansible_host }} "echo success"
140 register: user_enabled
141 until: user_enabled.stdout.find("success") != -1
145 when: reboot_node is changed
147 - name: Ensure directory for flag file
149 path: /etc/ansible-change_kernel_cmdline/
153 - name: Create a temporary flag file to indicate enabling of performance profile
156 dest: /etc/ansible-change_kernel_cmdline/enabled
162 - grub_cmdline.changed or grub_cmdline_default.changed or platform_affinity.changed
163 - hostname == installation_controller
165 - name: Ensure finalize-bootstrap.service is enabled on the installation host
167 name: finalize-bootstrap
170 - grub_cmdline.changed or grub_cmdline_default.changed or platform_affinity.changed
171 - hostname == installation_controller
173 - name: Set OS tunables in /etc/sysctl.d/os-tuning.conf
175 name: "{{ item.name }}"
176 value: "{{ item.value }}"
178 sysctl_file: "{{ os_tuning_conf_file }}"
181 - {name: 'vm.max_map_count', value: '300000'}
182 - {name: 'fs.inotify.max_user_instances', value: '1024'}