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: Check whether grub-efi exists
101 path: /boot/efi/EFI/centos/grub.cfg
102 register: grub_efi_file_stat
104 - name: Generate grub configurations
105 command: grub2-mkconfig -o /boot/grub2/grub.cfg
106 when: grub_cmdline.changed or grub_cmdline_default.changed
108 - name: Generate grub-efi configurations
109 command: grub2-mkconfig -o /boot/efi/EFI/centos/grub.cfg
111 - grub_cmdline.changed or grub_cmdline_default.changed
112 - grub_efi_file_stat.stat.exists == true
114 - name: Ensure network.service is enabled
119 - name: Set reboot command
121 reboot_cmd: "( sleep 3 && /sbin/reboot & )"
124 shell: "{{ reboot_cmd }}"
128 register: reboot_node
130 - grub_cmdline.changed or grub_cmdline_default.changed or platform_affinity.changed
131 - hostname != installation_controller
132 - 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)
134 - name: Wait for the server to reboot
136 host: "{{ansible_host}}"
139 search_regex: OpenSSH
143 register: remote_success
144 until: remote_success is succeeded
146 when: reboot_node is changed
148 - name: Wait for remote node ssh login. Wating for 10mins max.
149 become: "{{ ansible_env.SUDO_USER }}"
150 local_action: shell ssh -oBatchMode=yes -4 -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null {{ ansible_host }} "echo success"
151 register: user_enabled
152 until: user_enabled.stdout.find("success") != -1
156 when: reboot_node is changed
158 - name: Ensure directory for flag file
160 path: /etc/ansible-change_kernel_cmdline/
164 - name: Create a temporary flag file to indicate enabling of performance profile
167 dest: /etc/ansible-change_kernel_cmdline/enabled
173 - grub_cmdline.changed or grub_cmdline_default.changed or platform_affinity.changed
174 - hostname == installation_controller
176 - name: Ensure finalize-bootstrap.service is enabled on the installation host
178 name: finalize-bootstrap
181 - grub_cmdline.changed or grub_cmdline_default.changed or platform_affinity.changed
182 - hostname == installation_controller
184 - name: Set OS tunables in /etc/sysctl.d/os-tuning.conf
186 name: "{{ item.name }}"
187 value: "{{ item.value }}"
189 sysctl_file: "{{ os_tuning_conf_file }}"
192 - {name: 'vm.max_map_count', value: '300000'}
193 - {name: 'fs.inotify.max_user_instances', value: '1024'}