Merge "Adds network/cidr mapping into a new service property"
[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   DockerNamespace:
8     description: namespace
9     default: 'tripleoupstream'
10     type: string
11   DockerNeutronApiImage:
12     description: image
13     default: 'centos-binary-neutron-server:latest'
14     type: string
15   DockerNeutronConfigImage:
16     description: The container image to use for the neutron config_volume
17     default: 'centos-binary-neutron-server:latest'
18     type: string
19   EndpointMap:
20     default: {}
21     description: Mapping of service endpoint -> protocol. Typically set
22                  via parameter_defaults in the resource registry.
23     type: json
24   ServiceData:
25     default: {}
26     description: Dictionary packing service data
27     type: json
28   ServiceNetMap:
29     default: {}
30     description: Mapping of service_name -> network name. Typically set
31                  via parameter_defaults in the resource registry.  This
32                  mapping overrides those in ServiceNetMapDefaults.
33     type: json
34   DefaultPasswords:
35     default: {}
36     type: json
37   RoleName:
38     default: ''
39     description: Role name on which the service is applied
40     type: string
41   RoleParameters:
42     default: {}
43     description: Parameters specific to the role
44     type: json
45   EnableInternalTLS:
46     type: boolean
47     default: false
48
49 conditions:
50
51   internal_tls_enabled: {equals: [{get_param: EnableInternalTLS}, true]}
52
53 resources:
54
55   ContainersCommon:
56     type: ./containers-common.yaml
57
58   NeutronBase:
59     type: ../../puppet/services/neutron-api.yaml
60     properties:
61       EndpointMap: {get_param: EndpointMap}
62       ServiceData: {get_param: ServiceData}
63       ServiceNetMap: {get_param: ServiceNetMap}
64       DefaultPasswords: {get_param: DefaultPasswords}
65       RoleName: {get_param: RoleName}
66       RoleParameters: {get_param: RoleParameters}
67
68 outputs:
69   role_data:
70     description: Role data for the Neutron API role.
71     value:
72       service_name: {get_attr: [NeutronBase, role_data, service_name]}
73       config_settings:
74         map_merge:
75           - get_attr: [NeutronBase, role_data, config_settings]
76       step_config: &step_config
77         get_attr: [NeutronBase, 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:
85           list_join:
86             - '/'
87             - [ {get_param: DockerNamespace}, {get_param: DockerNeutronConfigImage} ]
88       kolla_config:
89         /var/lib/kolla/config_files/neutron_api.json:
90           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
91           config_files:
92             - source: "/var/lib/kolla/config_files/src/*"
93               dest: "/"
94               merge: true
95               preserve_properties: true
96           permissions:
97             - path: /var/log/neutron
98               owner: neutron:neutron
99               recurse: true
100         /var/lib/kolla/config_files/neutron_server_tls_proxy.json:
101           command: /usr/sbin/httpd -DFOREGROUND
102           config_files:
103             - source: "/var/lib/kolla/config_files/src/*"
104               dest: "/"
105               merge: true
106               preserve_properties: true
107       docker_config:
108         # db sync runs before permissions set by kolla_config
109         step_2:
110           neutron_init_logs:
111             image: &neutron_api_image
112               list_join:
113                 - '/'
114                 - [ {get_param: DockerNamespace}, {get_param: DockerNeutronApiImage} ]
115             privileged: false
116             user: root
117             volumes:
118               - /var/log/containers/neutron:/var/log/neutron
119             command: ['/bin/bash', '-c', 'chown -R neutron:neutron /var/log/neutron']
120         step_3:
121           neutron_db_sync:
122             image: *neutron_api_image
123             net: host
124             privileged: false
125             detach: false
126             user: root
127             volumes:
128               list_concat:
129                 - {get_attr: [ContainersCommon, volumes]}
130                 -
131                   - /var/lib/config-data/neutron/etc/neutron:/etc/neutron:ro
132                   - /var/lib/config-data/neutron/usr/share/neutron:/usr/share/neutron:ro
133                   - /var/log/containers/neutron:/var/log/neutron
134             command: ['/usr/bin/bootstrap_host_exec', 'neutron_api', 'neutron-db-manage', 'upgrade', 'heads']
135             # FIXME: we should make config file permissions right
136             # and run as neutron user
137             #command: "/usr/bin/bootstrap_host_exec neutron_api su neutron -s /bin/bash -c 'neutron-db-manage upgrade heads'"
138         step_4:
139           map_merge:
140             - neutron_api:
141                 image: *neutron_api_image
142                 net: host
143                 privileged: false
144                 restart: always
145                 volumes:
146                   list_concat:
147                     - {get_attr: [ContainersCommon, volumes]}
148                     -
149                       - /var/lib/kolla/config_files/neutron_api.json:/var/lib/kolla/config_files/config.json:ro
150                       - /var/lib/config-data/puppet-generated/neutron/:/var/lib/kolla/config_files/src:ro
151                       - /var/log/containers/neutron:/var/log/neutron
152                 environment:
153                   - KOLLA_CONFIG_STRATEGY=COPY_ALWAYS
154             - if:
155                 - internal_tls_enabled
156                 - neutron_server_tls_proxy:
157                     image: *neutron_api_image
158                     net: host
159                     user: root
160                     restart: always
161                     volumes:
162                       list_concat:
163                         - {get_attr: [ContainersCommon, volumes]}
164                         -
165                           - /var/lib/kolla/config_files/neutron_server_tls_proxy.json:/var/lib/kolla/config_files/config.json:ro
166                           - /var/lib/config-data/puppet-generated/neutron/:/var/lib/kolla/config_files/src:ro
167                           - /etc/pki/tls/certs/httpd:/etc/pki/tls/certs/httpd:ro
168                           - /etc/pki/tls/private/httpd:/etc/pki/tls/private/httpd:ro
169                     environment:
170                       - KOLLA_CONFIG_STRATEGY=COPY_ALWAYS
171                 - {}
172       host_prep_tasks:
173         - name: create persistent logs directory
174           file:
175             path: /var/log/containers/neutron
176             state: directory
177       upgrade_tasks:
178         - name: Stop and disable neutron_api service
179           tags: step2
180           service: name=neutron-server state=stopped enabled=no
181       metadata_settings:
182         get_attr: [NeutronBase, role_data, metadata_settings]