Use Python to compute release notes version
[apex-tripleo-heat-templates.git] / docker / services / neutron-api.yaml
1 heat_template_version: pike
2
3 description: >
4   OpenStack containerized Neutron API service
5
6 parameters:
7   DockerNeutronApiImage:
8     description: image
9     type: string
10   DockerNeutronConfigImage:
11     description: The container image to use for the neutron config_volume
12     type: string
13   EndpointMap:
14     default: {}
15     description: Mapping of service endpoint -> protocol. Typically set
16                  via parameter_defaults in the resource registry.
17     type: json
18   ServiceData:
19     default: {}
20     description: Dictionary packing service data
21     type: json
22   ServiceNetMap:
23     default: {}
24     description: Mapping of service_name -> network name. Typically set
25                  via parameter_defaults in the resource registry.  This
26                  mapping overrides those in ServiceNetMapDefaults.
27     type: json
28   DefaultPasswords:
29     default: {}
30     type: json
31   RoleName:
32     default: ''
33     description: Role name on which the service is applied
34     type: string
35   RoleParameters:
36     default: {}
37     description: Parameters specific to the role
38     type: json
39   EnableInternalTLS:
40     type: boolean
41     default: false
42
43 conditions:
44
45   internal_tls_enabled: {equals: [{get_param: EnableInternalTLS}, true]}
46
47 resources:
48
49   ContainersCommon:
50     type: ./containers-common.yaml
51
52   MySQLClient:
53     type: ../../puppet/services/database/mysql-client.yaml
54
55   NeutronBase:
56     type: ../../puppet/services/neutron-api.yaml
57     properties:
58       EndpointMap: {get_param: EndpointMap}
59       ServiceData: {get_param: ServiceData}
60       ServiceNetMap: {get_param: ServiceNetMap}
61       DefaultPasswords: {get_param: DefaultPasswords}
62       RoleName: {get_param: RoleName}
63       RoleParameters: {get_param: RoleParameters}
64
65 outputs:
66   role_data:
67     description: Role data for the Neutron API role.
68     value:
69       service_name: {get_attr: [NeutronBase, role_data, service_name]}
70       config_settings:
71         map_merge:
72           - get_attr: [NeutronBase, role_data, config_settings]
73       step_config: &step_config
74         list_join:
75           - "\n"
76           - - {get_attr: [NeutronBase, role_data, step_config]}
77             - {get_attr: [MySQLClient, role_data, step_config]}
78       service_config_settings: {get_attr: [NeutronBase, role_data, service_config_settings]}
79       # BEGIN DOCKER SETTINGS
80       puppet_config:
81         config_volume: neutron
82         puppet_tags: neutron_config,neutron_api_config
83         step_config: *step_config
84         config_image: {get_param: DockerNeutronConfigImage}
85       kolla_config:
86         /var/lib/kolla/config_files/neutron_api.json:
87           command: /usr/bin/neutron-server --config-file /usr/share/neutron/neutron-dist.conf --config-file /etc/neutron/neutron.conf --config-file /etc/neutron/plugin.ini --config-dir /etc/neutron/conf.d/common --config-dir /etc/neutron/conf.d/neutron-server
88           config_files:
89             - source: "/var/lib/kolla/config_files/src/*"
90               dest: "/"
91               merge: true
92               preserve_properties: true
93           permissions:
94             - path: /var/log/neutron
95               owner: neutron:neutron
96               recurse: true
97         /var/lib/kolla/config_files/neutron_server_tls_proxy.json:
98           command: /usr/sbin/httpd -DFOREGROUND
99           config_files:
100             - source: "/var/lib/kolla/config_files/src/*"
101               dest: "/"
102               merge: true
103               preserve_properties: true
104       docker_config:
105         # db sync runs before permissions set by kolla_config
106         step_2:
107           neutron_init_logs:
108             image: &neutron_api_image {get_param: DockerNeutronApiImage}
109             privileged: false
110             user: root
111             volumes:
112               - /var/log/containers/neutron:/var/log/neutron
113             command: ['/bin/bash', '-c', 'chown -R neutron:neutron /var/log/neutron']
114         step_3:
115           neutron_db_sync:
116             image: *neutron_api_image
117             net: host
118             privileged: false
119             detach: false
120             user: root
121             volumes:
122               list_concat:
123                 - {get_attr: [ContainersCommon, volumes]}
124                 -
125                   - /var/lib/config-data/neutron/etc/my.cnf.d/tripleo.cnf:/etc/my.cnf.d/tripleo.cnf:ro
126                   - /var/lib/config-data/neutron/etc/neutron:/etc/neutron:ro
127                   - /var/lib/config-data/neutron/usr/share/neutron:/usr/share/neutron:ro
128                   - /var/log/containers/neutron:/var/log/neutron
129             command: ['/usr/bin/bootstrap_host_exec', 'neutron_api', 'neutron-db-manage', 'upgrade', 'heads']
130             # FIXME: we should make config file permissions right
131             # and run as neutron user
132             #command: "/usr/bin/bootstrap_host_exec neutron_api su neutron -s /bin/bash -c 'neutron-db-manage upgrade heads'"
133         step_4:
134           map_merge:
135             - neutron_api:
136                 image: *neutron_api_image
137                 net: host
138                 privileged: false
139                 restart: always
140                 volumes:
141                   list_concat:
142                     - {get_attr: [ContainersCommon, volumes]}
143                     -
144                       - /var/lib/kolla/config_files/neutron_api.json:/var/lib/kolla/config_files/config.json:ro
145                       - /var/lib/config-data/puppet-generated/neutron/:/var/lib/kolla/config_files/src:ro
146                       - /var/log/containers/neutron:/var/log/neutron
147                 environment:
148                   - KOLLA_CONFIG_STRATEGY=COPY_ALWAYS
149             - if:
150                 - internal_tls_enabled
151                 - neutron_server_tls_proxy:
152                     image: *neutron_api_image
153                     net: host
154                     user: root
155                     restart: always
156                     volumes:
157                       list_concat:
158                         - {get_attr: [ContainersCommon, volumes]}
159                         -
160                           - /var/lib/kolla/config_files/neutron_server_tls_proxy.json:/var/lib/kolla/config_files/config.json:ro
161                           - /var/lib/config-data/puppet-generated/neutron/:/var/lib/kolla/config_files/src:ro
162                           - /etc/pki/tls/certs/httpd:/etc/pki/tls/certs/httpd:ro
163                           - /etc/pki/tls/private/httpd:/etc/pki/tls/private/httpd:ro
164                     environment:
165                       - KOLLA_CONFIG_STRATEGY=COPY_ALWAYS
166                 - {}
167       host_prep_tasks:
168         - name: create persistent logs directory
169           file:
170             path: /var/log/containers/neutron
171             state: directory
172       upgrade_tasks:
173         - name: Check if neutron_server is deployed
174           command: systemctl is-enabled neutron-server
175           tags: common
176           ignore_errors: True
177           register: neutron_server_enabled
178         - name: "PreUpgrade step0,validation: Check service neutron-server is running"
179           shell: /usr/bin/systemctl show 'neutron-server' --property ActiveState | grep '\bactive\b'
180           when: neutron_server_enabled.rc == 0
181           tags: step0,validation
182         - name: Stop and disable neutron_api service
183           tags: step2
184           when: neutron_server_enabled.rc == 0
185           service: name=neutron-server state=stopped enabled=no
186       metadata_settings:
187         get_attr: [NeutronBase, role_data, metadata_settings]