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