Merge "Repurpose KeystoneWorkers add keystone::wsgi::apache::threads"
[apex-tripleo-heat-templates.git] / docker / compute-post.yaml
1 heat_template_version: 2015-10-15
2 description: >
3   OpenStack compute node post deployment for Docker.
4
5 parameters:
6   servers:
7     type: json
8   DeployIdentifier:
9      type: string
10      description: Value which changes if the node configuration may need to be re-applied
11   DockerNamespace:
12     type: string
13     default: tripleoupstream
14   DockerComputeImage:
15     type: string
16   DockerComputeDataImage:
17     type: string
18   DockerLibvirtImage:
19     type: string
20   DockerOpenvswitchImage:
21     type: string
22   DockerOvsVswitchdImage:
23     type: string
24   DockerOpenvswitchDBImage:
25     type: string
26   LibvirtConfig:
27     type: string
28     default: "/etc/libvirt/libvirtd.conf"
29   NovaConfig:
30     type: string
31     default: "/etc/nova/nova.conf,/etc/nova/rootwrap.conf"
32   NeutronOpenvswitchAgentConfig:
33     type: string
34     default: "/etc/neutron/neutron.conf,/etc/neutron/plugins/openvswitch/ovs_neutron_plugin.ini"
35   NeutronOpenvswitchAgentPluginVolume:
36     type: string
37     default: "/var/lib/etc-data/neutron/plugins/ml2/openvswitch_agent.ini:/var/lib/kolla/config_files/ovs_neutron_plugin.ini:ro"
38   NeutronOpenvswitchAgentOvsVolume:
39     type: string
40     default: " "
41   StepConfig:
42     type: string
43     description: Config manifests that will be used to step through the deployment.
44     default: ''
45
46
47 resources:
48
49   ComputePuppetConfig:
50     type: OS::Heat::SoftwareConfig
51     properties:
52       group: puppet
53       options:
54         enable_hiera: True
55         enable_facter: False
56         tags: package,file,concat,file_line,nova_config,neutron_config,neutron_agent_ovs,neutron_plugin_ml2
57       inputs:
58       - name: tripleo::packages::enable_install
59         type: Boolean
60         default: True
61       outputs:
62       - name: result
63       config:
64         list_join:
65         - ''
66         - - get_file: ../puppet/manifests/overcloud_compute.pp
67           - {get_param: StepConfig}
68
69
70   ComputePuppetDeployment:
71     type: OS::Heat::SoftwareDeployments
72     properties:
73       name: ComputePuppetDeployment
74       servers:  {get_param: servers}
75       config: {get_resource: ComputePuppetConfig}
76       input_values:
77         update_identifier: {get_param: DeployIdentifier}
78         tripleo::packages::enable_install: True
79
80   CopyEtcConfig:
81     type: OS::Heat::SoftwareConfig
82     properties:
83       group: script
84       outputs:
85       - name: result
86       config: {get_file: ./copy-etc.sh}
87
88   CopyEtcDeployment:
89     type: OS::Heat::SoftwareDeployments
90     depends_on: ComputePuppetDeployment
91     properties:
92       name: CopyEtcDeployment
93       config: {get_resource: CopyEtcConfig}
94       servers:  {get_param: servers}
95
96   CopyJsonConfig:
97     type: OS::Heat::SoftwareConfig
98     properties:
99       group: script
100       inputs:
101       - name: libvirt_config
102       - name: nova_config
103       - name: neutron_openvswitch_agent_config
104       config: |
105         #!/bin/python
106         import json
107         import os
108
109         data = {}
110         file_perms = '600'
111         libvirt_perms = '644'
112
113         libvirt_config = os.getenv('libvirt_config').split(',')
114         nova_config = os.getenv('nova_config').split(',')
115         neutron_openvswitch_agent_config = os.getenv('neutron_openvswitch_agent_config').split(',')
116
117         # Command, Config_files, Owner, Perms
118         services = {'nova-libvirt': ['/usr/sbin/libvirtd', libvirt_config, 'root', libvirt_perms],
119                     'nova-compute': ['/usr/bin/nova-compute', nova_config, 'nova', file_perms],
120                     'neutron-openvswitch-agent': ['/usr/bin/neutron-openvswitch-agent', neutron_openvswitch_agent_config, 'neutron', file_perms],
121                     'ovs-vswitchd': ['/usr/sbin/ovs-vswitchd unix:/run/openvswitch/db.sock -vconsole:emer -vsyslog:err -vfile:info --mlockall --log-file=/var/log/openvswitch/ovs-vswitchd.log'],
122                     'ovsdb-server': ['/usr/sbin/ovsdb-server /etc/openvswitch/conf.db -vconsole:emer -vsyslog:err -vfile:info --remote=punix:/run/openvswitch/db.sock --log-file=/var/log/openvswitch/ovsdb-server.log']
123                    }
124
125
126         def build_config_files(config, owner, perms):
127             config_source = '/var/lib/kolla/config_files/'
128             config_files_dict = {}
129             source = os.path.basename(config)
130             dest = config
131             config_files_dict.update({'source': config_source + source,
132                                       'dest': dest,
133                                       'owner': owner,
134                                       'perm': perms})
135             return config_files_dict
136
137
138         for service in services:
139             if service != 'ovs-vswitchd' and service != 'ovsdb-server':
140                 command = services.get(service)[0]
141                 config_files = services.get(service)[1]
142                 owner = services.get(service)[2]
143                 perms = services.get(service)[3]
144                 config_files_list = []
145                 for config_file in config_files:
146                     if service == 'nova-libvirt':
147                         command = command + ' --config ' + config_file
148                     else:
149                         command = command + ' --config-file ' + config_file
150                     data['command'] = command
151                     config_files_dict = build_config_files(config_file, owner, perms)
152                     config_files_list.append(config_files_dict)
153                 data['config_files'] = config_files_list
154             else:
155                 data['command'] = services.get(service)[0]
156                 data['config_files'] = []
157
158             json_config_dir = '/var/lib/etc-data/json-config/'
159             with open(json_config_dir + service + '.json', 'w') as json_file:
160                 json.dump(data, json_file, sort_keys=True, indent=4, separators=(',', ': '))
161
162   CopyJsonDeployment:
163     type: OS::Heat::SoftwareDeployments
164     depends_on: CopyEtcDeployment
165     properties:
166       name: CopyJsonDeployment
167       config: {get_resource: CopyJsonConfig}
168       servers:  {get_param: servers}
169       input_values:
170         libvirt_config: {get_param: LibvirtConfig}
171         nova_config: {get_param: NovaConfig}
172         neutron_openvswitch_agent_config: {get_param: NeutronOpenvswitchAgentConfig}
173
174   NovaComputeContainersDeploymentOVS:
175     type: OS::Heat::StructuredDeployments
176     depends_on: CopyJsonDeployment
177     properties:
178       name: NovaComputeContainersDeploymentOVS
179       config: {get_resource: NovaComputeContainersConfigOVS}
180       servers: {get_param: servers}
181
182   NovaComputeContainersConfigOVS:
183     type: OS::Heat::StructuredConfig
184     properties:
185       group: docker-cmd
186       config:
187         ovsvswitchd:
188           image:
189             list_join:
190             - '/'
191             - [ {get_param: DockerNamespace}, {get_param: DockerOvsVswitchdImage} ]
192           net: host
193           privileged: true
194           restart: always
195           volumes:
196            - /run:/run
197            - /lib/modules:/lib/modules:ro
198            - /var/lib/etc-data/json-config/ovs-vswitchd.json:/var/lib/kolla/config_files/config.json
199           environment:
200            - KOLLA_CONFIG_STRATEGY=COPY_ALWAYS
201
202         openvswitchdb:
203           image:
204             list_join:
205             - '/'
206             - [ {get_param: DockerNamespace}, {get_param: DockerOpenvswitchDBImage} ]
207           net: host
208           restart: always
209           volumes:
210            - /run:/run
211            - /var/lib/etc-data/json-config/ovsdb-server.json:/var/lib/kolla/config_files/config.json
212            - /etc/openvswitchd:/etc/openvswitchd
213           environment:
214            - KOLLA_CONFIG_STRATEGY=COPY_ALWAYS
215
216   NovaComputeContainersDeploymentNetconfig:
217     type: OS::Heat::SoftwareDeployments
218     depends_on: NovaComputeContainersDeploymentOVS
219     properties:
220       name: NovaComputeContainersDeploymentNetconfig
221       config: {get_resource: NovaComputeContainersConfigNetconfig}
222       servers: {get_param: servers}
223
224   # We run os-net-config here because we depend on the ovs containers to be up
225   # and running before we configure the network.  This allows explicit timing
226   # of the network configuration.
227   NovaComputeContainersConfigNetconfig:
228     type: OS::Heat::SoftwareConfig
229     properties:
230       group: script
231       outputs:
232       - name: result
233       config: |
234         #!/bin/bash
235         /usr/local/bin/run-os-net-config
236
237   LibvirtContainersDeployment:
238     type: OS::Heat::StructuredDeployments
239     depends_on: [CopyJsonDeployment, CopyEtcDeployment, ComputePuppetDeployment, NovaComputeContainersDeploymentNetconfig]
240     properties:
241       name: LibvirtContainersDeployment
242       config: {get_resource: LibvirtContainersConfig}
243       servers: {get_param: servers}
244
245   LibvirtContainersConfig:
246     type: OS::Heat::StructuredConfig
247     properties:
248       group: docker-cmd
249       config:
250         computedata:
251           image:
252             list_join:
253             - '/'
254             - [ {get_param: DockerNamespace}, {get_param: DockerComputeDataImage} ]
255           container_name: computedata
256           volumes:
257            - /var/lib/nova/instances
258            - /var/lib/libvirt
259
260         libvirt:
261           image:
262             list_join:
263             - '/'
264             - [ {get_param: DockerNamespace}, {get_param: DockerLibvirtImage} ]
265           net: host
266           pid: host
267           privileged: true
268           restart: always
269           volumes:
270            - /run:/run
271            - /lib/modules:/lib/modules:ro
272            - /dev:/dev
273            - /lib/udev:/lib/udev
274            - /sys/fs/cgroup:/sys/fs/cgroup
275            - /var/lib/etc-data/json-config/nova-libvirt.json:/var/lib/kolla/config_files/config.json
276            - /var/lib/etc-data/libvirt/libvirtd.conf:/var/lib/kolla/config_files/libvirtd.conf
277           environment:
278            - KOLLA_CONFIG_STRATEGY=COPY_ALWAYS
279           volumes_from:
280            - computedata
281
282   NovaComputeContainersDeployment:
283     type: OS::Heat::StructuredDeployments
284     depends_on: [CopyJsonDeployment, CopyEtcDeployment, ComputePuppetDeployment, NovaComputeContainersDeploymentNetconfig, LibvirtContainersDeployment]
285     properties:
286       name: NovaComputeContainersDeployment
287       config: {get_resource: NovaComputeContainersConfig}
288       servers: {get_param: servers}
289
290   NovaComputeContainersConfig:
291     type: OS::Heat::StructuredConfig
292     properties:
293       group: docker-cmd
294       config:
295         neutronovsagent:
296           image:
297             list_join:
298             - '/'
299             - [ {get_param: DockerNamespace}, {get_param: DockerOpenvswitchImage} ]
300           net: host
301           pid: host
302           privileged: true
303           restart: always
304           volumes:
305             str_split:
306               - ","
307               - list_join:
308                  - ","
309                  - [ "/run:/run", "/lib/modules:/lib/modules:ro",
310                      "/var/lib/etc-data/json-config/neutron-openvswitch-agent.json:/var/lib/kolla/config_files/config.json",
311                      "/var/lib/etc-data/neutron/neutron.conf:/var/lib/kolla/config_files/neutron.conf:ro",
312                      "/var/lib/etc-data/neutron/plugins/ml2/ml2_conf.ini:/var/lib/kolla/config_files/ml2_conf.ini:ro",
313                      {get_param: NeutronOpenvswitchAgentPluginVolume},
314                      {get_param: NeutronOpenvswitchAgentOvsVolume} ]
315           environment:
316            - KOLLA_CONFIG_STRATEGY=COPY_ALWAYS
317           volumes_from:
318            - computedata
319
320         novacompute:
321           image:
322             list_join:
323             - '/'
324             - [ {get_param: DockerNamespace}, {get_param: DockerComputeImage} ]
325           net: host
326           privileged: true
327           restart: always
328           volumes:
329            - /run:/run
330            - /lib/modules:/lib/modules:ro
331            - /dev:/dev
332            - /lib/udev:/lib/udev
333            - /etc/iscsi:/etc/iscsi
334            - /var/lib/etc-data/json-config/nova-compute.json:/var/lib/kolla/config_files/config.json
335            - /var/lib/etc-data/nova/nova.conf:/var/lib/kolla/config_files/nova.conf:ro
336            - /var/lib/etc-data/nova/rootwrap.conf:/var/lib/kolla/config_files/rootwrap.conf:ro
337           environment:
338            - KOLLA_CONFIG_STRATEGY=COPY_ALWAYS
339           volumes_from:
340            - computedata
341
342   ExtraConfig:
343     depends_on: NovaComputeContainersDeployment
344     type: OS::TripleO::NodeExtraConfigPost
345     properties:
346         servers: {get_param: servers}