Merge "Stop also openstack-swift-object-expirer when upgrading swift services"
[apex-tripleo-heat-templates.git] / extraconfig / pre_network / host_config_and_reboot.yaml
1 heat_template_version: pike
2
3 description: >
4   All configurations which require reboot should be initiated via PreNetworkConfig. After
5   this configuration is completed, the corresponding node will be rebooted.
6
7 parameters:
8   server:
9     type: string
10   RoleParameters:
11     type: json
12     description: Role Specific parameters
13     default: {}
14   ServiceNames:
15     type: comma_delimited_list
16     default: []
17   OvsEnableDpdk:
18     default: false
19     description: Whether or not to configure enable DPDK in OVS
20     type: boolean
21   OvsDpdkCoreList:
22     description: >
23       List of cores to be used for DPDK lcore threads.  Note, these threads
24       are used by the OVS control path for validator and handling functions.
25     type: string
26     constraints:
27       - allowed_pattern: "[0-9,-]*"
28     default: ""
29   OvsDpdkMemoryChannels:
30     description: Number of memory channels per socket to be used for DPDK
31     type: string
32     constraints:
33       - allowed_pattern: "[0-9]*"
34     default: ""
35   OvsDpdkSocketMemory:
36     default: ""
37     description: >
38       Sets the amount of hugepage memory to assign per NUMA node. It is
39       recommended to use the socket closest to the PCIe slot used for the
40       desired DPDK NIC.  The format should be in "<socket 0 mem>, <socket 1
41       mem>, <socket n mem>", where the value is specified in MB.  For example:
42       "1024,0".
43     type: string
44   OvsPmdCoreList:
45     description: >
46       A list or range of CPU cores for PMD threads to be pinned to.  Note, NIC
47       location to cores on socket, number of hyper-threaded logical cores, and
48       desired number of PMD threads can all play a role in configuring this
49       setting.  These cores should be on the same socket where
50       OvsDpdkSocketMemory is assigned.  If using hyperthreading then specify
51       both logical cores that would equal the physical core. Also, specifying
52       more than one core will trigger multiple PMD threads to be spawned which
53       may improve dataplane performance.
54     constraints:
55       - allowed_pattern: "[0-9,-]*"
56     type: string
57     default: ""
58   # DEPRECATED: the following options are deprecated and are currently maintained
59   # for backwards compatibility. They will be removed in the Queens cycle.
60   HostCpusList:
61     description: List of cores to be used for host process
62     type: string
63     constraints:
64       - allowed_pattern: "[0-9,-]+"
65     default: '0'
66   NeutronDpdkCoreList:
67     description: List of cores to be used for DPDK Poll Mode Driver
68     type: string
69     constraints:
70       - allowed_pattern: "[0-9,-]*"
71     default: ''
72   NeutronDpdkMemoryChannels:
73     description: Number of memory channels to be used for DPDK
74     type: string
75     constraints:
76       - allowed_pattern: "[0-9]*"
77     default: ''
78   NeutronDpdkSocketMemory:
79     default: ''
80     description: Memory allocated for each socket
81     type: string
82   deployment_actions:
83     default: ['CREATE', 'UPDATE']
84     type: comma_delimited_list
85     description: >
86       List of stack actions that will trigger any deployments in this
87       templates. The actions will be an empty list of the server is in the
88       toplevel DeploymentServerBlacklist parameter's value.
89
90 conditions:
91   is_host_config_required: {not: {equals: [{get_param: [RoleParameters, KernelArgs]}, ""]}}
92   is_dpdk_config_required:
93     or:
94       - yaql:
95           expression: $.data.service_names.contains('neutron_ovs_dpdk_agent')
96           data:
97             service_names: {get_param: ServiceNames}
98       - {equals: [{get_param: [RoleParameters, OvsEnableDpdk]}, true]}
99   is_reboot_config_required:
100     or:
101       - is_host_config_required
102       - is_dpdk_config_required
103   l_cores_empty: {equals: [{get_param: OvsDpdkCoreList}, '']}
104   pmd_cores_empty: {equals: [{get_param: OvsPmdCoreList}, '']}
105   mem_channels_empty: {equals: [{get_param: OvsDpdkMemoryChannels}, '']}
106   socket_mem_empty: {equals: [{get_param: OvsDpdkSocketMemory}, '']}
107   deployment_actions_empty:
108     equals:
109       - {get_param: deployment_actions}
110       - []
111
112 resources:
113   RoleParametersValue:
114     type: OS::Heat::Value
115     properties:
116       type: json
117       value:
118         map_replace:
119           - map_replace:
120             - OvsDpdkCoreList: OvsDpdkCoreList
121               OvsDpdkMemoryChannels: OvsDpdkMemoryChannels
122               OvsDpdkSocketMemory: OvsDpdkSocketMemory
123               OvsPmdCoreList: OvsPmdCoreList
124             - values: {get_param: [RoleParameters]}
125           - values:
126               OvsDpdkCoreList: {if: [l_cores_empty, {get_param: HostCpusList}, {get_param: OvsDpdkCoreList}]}
127               OvsDpdkMemoryChannels: {if: [mem_channels_empty, {get_param: NeutronDpdkMemoryChannels}, {get_param: OvsDpdkMemoryChannels}]}
128               OvsDpdkSocketMemory: {if: [socket_mem_empty, {get_param: NeutronDpdkSocketMemory}, {get_param: OvsDpdkSocketMemory}]}
129               OvsPmdCoreList: {if: [pmd_cores_empty, {get_param: NeutronDpdkCoreList}, {get_param: OvsPmdCoreList}]}
130
131   HostParametersConfig:
132     type: OS::Heat::SoftwareConfig
133     condition: is_host_config_required
134     properties:
135       group: ansible
136       inputs:
137         - name: _KERNEL_ARGS_
138         - name: _TUNED_PROFILE_NAME_
139         - name: _TUNED_CORES_
140       outputs:
141         - name: result
142       config:
143         get_file: ansible_host_config.yaml
144
145   HostParametersDeployment:
146     type: OS::Heat::SoftwareDeployment
147     condition: is_host_config_required
148     properties:
149       name: HostParametersDeployment
150       server:  {get_param: server}
151       config: {get_resource: HostParametersConfig}
152       actions:
153         if:
154           - deployment_actions_empty
155           - []
156           - ['CREATE'] # Only do this on CREATE
157       input_values:
158         _KERNEL_ARGS_: {get_param: [RoleParameters, KernelArgs]}
159         _TUNED_PROFILE_NAME_: {get_param: [RoleParameters, TunedProfileName]}
160         _TUNED_CORES_: {get_param: [RoleParameters, IsolCpusList]}
161
162   EnableDpdkConfig:
163     type: OS::Heat::SoftwareConfig
164     condition: is_dpdk_config_required
165     properties:
166       group: script
167       config:
168         str_replace:
169           template: |
170             #!/bin/bash
171             set -x
172
173             # OvS Permission issue temporary workaround
174             # https://bugzilla.redhat.com/show_bug.cgi?id=1459436
175             # Actual solution from openvswitch - https://mail.openvswitch.org/pipermail/ovs-dev/2017-June/333423.html
176             ovs_service_path="/usr/lib/systemd/system/ovs-vswitchd.service"
177
178             if grep -q 'RuntimeDirectoryMode' $ovs_service_path; then
179                 sed -i 's/RuntimeDirectoryMode=.*/RuntimeDirectoryMode=0775/' $ovs_service_path
180             else
181                 echo "RuntimeDirectoryMode=0775" >> $ovs_service_path
182             fi
183
184             if ! grep -Fxq "Group=qemu" $ovs_service_path ; then
185               echo "Group=qemu" >> $ovs_service_path
186             fi
187
188             if ! grep -Fxq "UMask=0002" $ovs_service_path ; then
189               echo "UMask=0002" >> $ovs_service_path
190             fi
191
192             ovs_ctl_path='/usr/share/openvswitch/scripts/ovs-ctl'
193             if ! grep -q "umask 0002 \&\& start_daemon \"\$OVS_VSWITCHD_PRIORITY\"" $ovs_ctl_path ; then
194               sed -i 's/start_daemon \"\$OVS_VSWITCHD_PRIORITY\"/umask 0002 \&\& start_daemon \"$OVS_VSWITCHD_PRIORITY\"/' $ovs_ctl_path
195             fi
196
197
198             # DO NOT use --detailed-exitcodes
199             puppet apply --logdest console \
200               --modulepath /etc/puppet/modules:/opt/stack/puppet-modules:/usr/share/openstack-puppet/modules \
201               -e '
202                 class {"vswitch::dpdk":
203                   host_core_list  => "$HOST_CORES",
204                   pmd_core_list   => "$PMD_CORES",
205                   memory_channels => "$MEMORY_CHANNELS",
206                   socket_mem      => "$SOCKET_MEMORY",
207                 }
208               '
209           params:
210             $HOST_CORES: {get_attr: [RoleParametersValue, value, OvsDpdkCoreList]}
211             $PMD_CORES: {get_attr: [RoleParametersValue, value, OvsPmdCoreList]}
212             $MEMORY_CHANNELS: {get_attr: [RoleParametersValue, value, OvsDpdkMemoryChannels]}
213             $SOCKET_MEMORY: {get_attr: [RoleParametersValue, value, OvsDpdkSocketMemory]}
214
215   EnableDpdkDeployment:
216     type: OS::Heat::SoftwareDeployment
217     condition: is_dpdk_config_required
218     properties:
219       name: EnableDpdkDeployment
220       server:  {get_param: server}
221       config: {get_resource: EnableDpdkConfig}
222       actions:
223         if:
224           - deployment_actions_empty
225           - []
226           - ['CREATE'] # Only do this on CREATE
227
228   RebootConfig:
229     type: OS::Heat::SoftwareConfig
230     condition: is_reboot_config_required
231     properties:
232       group: script
233       config: |
234         #!/bin/bash
235         # Stop os-collect-config to avoid any race collecting another
236         # deployment before reboot happens
237         systemctl stop os-collect-config.service
238         /sbin/reboot
239
240   RebootDeployment:
241     type: OS::Heat::SoftwareDeployment
242     depends_on: HostParametersDeployment
243     condition: is_reboot_config_required
244     properties:
245       name: RebootDeployment
246       server:  {get_param: server}
247       config: {get_resource: RebootConfig}
248       actions:
249         if:
250           - deployment_actions_empty
251           - []
252           - ['CREATE'] # Only do this on CREATE
253       signal_transport: NO_SIGNAL
254
255 outputs:
256   result:
257     condition: is_host_config_required
258     value:
259       get_attr: [HostParametersDeployment, result]
260   stdout:
261     condition: is_host_config_required
262     value:
263       get_attr: [HostParametersDeployment, deploy_stdout]
264   stderr:
265     condition: is_host_config_required
266     value:
267       get_attr: [HostParametersDeployment, deploy_stderr]
268   status_code:
269     condition: is_host_config_required
270     value:
271       get_attr: [HostParametersDeployment, deploy_status_code]