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