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