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.ncir_cpu_allocation | default([]) }}"
27 - name: Make combined CPU lists.
29 cpu_alloc: "{{ cpu_alloc | cpulist_combine(item['name'], item['lists']) }}"
31 - { 'name': 'app', 'lists': ['ovs_dpdk', 'vm'] }
33 - name: Make sure configuration directory exists.
35 path: /etc/systemd/system.conf.d
39 - name: Set platform CPU affinity.
41 dest: /etc/systemd/system.conf.d/00affinity.conf
45 value: "{{ cpu_alloc['platform']['set'] | join(' ') }}"
47 register: platform_affinity
48 when: cpu_alloc | length > 0
50 - name: Make CPU list parameters.
52 kcmdline_default_list: "{{ kcmdline_default_list + [ item['opt'] + '=' + cpu_alloc[item['list']]['list'] ] }}"
54 - { 'opt': 'irqaffinity', 'list': 'platform' }
55 - { 'opt': 'kthread', 'list': 'platform' }
56 - { 'opt': 'nohz_full', 'list': 'app' }
57 - { 'opt': 'rcu_nocbs', 'list': 'app' }
58 - { 'opt': 'isolcpus', 'list': 'ovs_dpdk' }
59 when: "item['list'] in cpu_alloc"
61 - name: Make hugepage parameters.
63 kcmdline_default_list: "{{ kcmdline_default_list + [ item + '=' + perf_profile[item] | string ] }}"
64 with_items: ['default_hugepagesz', 'hugepagesz', 'hugepages']
65 when: item in perf_profile
70 - name: Set common kernel parameters.
72 name: /etc/default/grub
73 regexp: "^GRUB_CMDLINE_LINUX="
74 line: "GRUB_CMDLINE_LINUX='{{ kcmdline_list | list_to_cmdline }}'"
75 register: grub_cmdline
78 var: kcmdline_default_list
80 - name: Set default kernel parameters.
82 name: /etc/default/grub
83 regexp: "^GRUB_CMDLINE_LINUX_DEFAULT="
84 line: "GRUB_CMDLINE_LINUX_DEFAULT='{{ kcmdline_default_list | list_to_cmdline }}'"
85 register: grub_cmdline_default
87 - name: Generate grub configurations
88 command: grub2-mkconfig -o /boot/grub2/grub.cfg
89 when: grub_cmdline.changed or grub_cmdline_default.changed
91 - name: Ensure network.service is enabled
97 shell: ( sleep 3 && /sbin/reboot & )
102 - grub_cmdline.changed or grub_cmdline_default.changed or platform_affinity.changed
103 - hostname != installation_controller
104 - 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)
106 - name: Wait for the server to reboot
107 local_action: wait_for host="{{ansible_host}}" delay=15 state=started port=22 connect_timeout=10 timeout=720
109 - grub_cmdline.changed or grub_cmdline_default.changed or platform_affinity.changed
110 - hostname != installation_controller
111 - 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)
113 - name: Wait for remote node ssh login. Wating for 10mins max.
114 become: "{{ ansible_env.SUDO_USER }}"
115 local_action: shell ssh -oBatchMode=yes -4 -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null {{ ansible_host }} "echo success"
116 register: user_enabled
117 until: user_enabled.stdout.find("success") != -1
122 - grub_cmdline.changed or grub_cmdline_default.changed or platform_affinity.changed
123 - hostname != installation_controller
124 - 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)
126 - name: Ensure directory for flag file
128 path: /etc/ansible-change_kernel_cmdline/
132 - name: Create a temporary flag file to indicate enabling of performance profile
135 dest: /etc/ansible-change_kernel_cmdline/enabled
141 - grub_cmdline.changed or grub_cmdline_default.changed or platform_affinity.changed
142 - hostname == installation_controller
144 - name: Ensure finalize-bootstrap.service is enabled on the installation host
146 name: finalize-bootstrap
149 - grub_cmdline.changed or grub_cmdline_default.changed or platform_affinity.changed
150 - hostname == installation_controller
152 - name: Set OS tunables in /etc/sysctl.d/os-tuning.conf
154 name: "{{ item.name }}"
155 value: "{{ item.value }}"
157 sysctl_file: "{{ os_tuning_conf_file }}"
160 - {name: 'vm.max_map_count', value: '300000'}
161 - {name: 'fs.inotify.max_user_instances', value: '1024'}