Merge "Generate MySQL client config if service requires database"
[apex-tripleo-heat-templates.git] / docker / services / glance-api.yaml
1 heat_template_version: pike
2
3 description: >
4   OpenStack Glance service configured with Puppet
5
6 parameters:
7   DockerGlanceApiImage:
8     description: image
9     type: string
10   DockerGlanceApiConfigImage:
11     description: The container image to use for the glance_api 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
48 resources:
49
50   ContainersCommon:
51     type: ./containers-common.yaml
52
53   MySQLClient:
54     type: ../../puppet/services/database/mysql-client.yaml
55
56   GlanceApiPuppetBase:
57     type: ../../puppet/services/glance-api.yaml
58     properties:
59       EndpointMap: {get_param: EndpointMap}
60       ServiceData: {get_param: ServiceData}
61       ServiceNetMap: {get_param: ServiceNetMap}
62       DefaultPasswords: {get_param: DefaultPasswords}
63       RoleName: {get_param: RoleName}
64       RoleParameters: {get_param: RoleParameters}
65
66 outputs:
67   role_data:
68     description: Role data for the Glance API role.
69     value:
70       service_name: {get_attr: [GlanceApiPuppetBase, role_data, service_name]}
71       config_settings:
72         map_merge:
73           - get_attr: [GlanceApiPuppetBase, role_data, config_settings]
74           - glance::api::sync_db: false
75       step_config: &step_config
76         list_join:
77           - "\n"
78           - - {get_attr: [GlanceApiPuppetBase, role_data, step_config]}
79             - {get_attr: [MySQLClient, role_data, step_config]}
80       service_config_settings: {get_attr: [GlanceApiPuppetBase, role_data, service_config_settings]}
81       # BEGIN DOCKER SETTINGS #
82       puppet_config:
83         config_volume: glance_api
84         puppet_tags: glance_api_config,glance_api_paste_ini,glance_swift_config,glance_cache_config
85         step_config: *step_config
86         config_image: {get_param: DockerGlanceApiConfigImage}
87       kolla_config:
88         /var/lib/kolla/config_files/glance_api.json:
89           command: /usr/bin/glance-api --config-file /usr/share/glance/glance-api-dist.conf --config-file /etc/glance/glance-api.conf
90           config_files:
91             - source: "/var/lib/kolla/config_files/src/*"
92               dest: "/"
93               merge: true
94               preserve_properties: true
95             - source: "/var/lib/kolla/config_files/src-ceph/"
96               dest: "/etc/ceph/"
97               merge: true
98               preserve_properties: true
99         /var/lib/kolla/config_files/glance_api_tls_proxy.json:
100           command: /usr/sbin/httpd -DFOREGROUND
101           config_files:
102             - source: "/var/lib/kolla/config_files/src/*"
103               dest: "/"
104               merge: true
105               preserve_properties: true
106       docker_config:
107         # Kolla_bootstrap/db_sync runs before permissions set by kolla_config
108         step_2:
109           glance_init_logs:
110             image: &glance_api_image {get_param: DockerGlanceApiImage}
111             privileged: false
112             user: root
113             volumes:
114               - /var/log/containers/glance:/var/log/glance
115             command: ['/bin/bash', '-c', 'chown -R glance:glance /var/log/glance']
116         step_3:
117           glance_api_db_sync:
118             image: *glance_api_image
119             net: host
120             privileged: false
121             detach: false
122             user: root
123             volumes: &glance_volumes
124               list_concat:
125                 - {get_attr: [ContainersCommon, volumes]}
126                 -
127                   - /var/lib/kolla/config_files/glance_api.json:/var/lib/kolla/config_files/config.json
128                   - /var/lib/config-data/puppet-generated/glance_api/:/var/lib/kolla/config_files/src:ro
129                   - /var/log/containers/glance:/var/log/glance
130                   - /etc/ceph:/var/lib/kolla/config_files/src-ceph:ro
131             environment:
132               - KOLLA_BOOTSTRAP=True
133               - KOLLA_CONFIG_STRATEGY=COPY_ALWAYS
134             command: "/usr/bin/bootstrap_host_exec glance_api su glance -s /bin/bash -c '/usr/local/bin/kolla_start'"
135         step_4:
136           map_merge:
137             - glance_api:
138                 start_order: 2
139                 image: *glance_api_image
140                 net: host
141                 privileged: false
142                 restart: always
143                 volumes: *glance_volumes
144                 environment:
145                   - KOLLA_CONFIG_STRATEGY=COPY_ALWAYS
146             - if:
147                 - internal_tls_enabled
148                 - glance_api_tls_proxy:
149                     start_order: 2
150                     image: *glance_api_image
151                     net: host
152                     user: root
153                     restart: always
154                     volumes:
155                       list_concat:
156                         - {get_attr: [ContainersCommon, volumes]}
157                         -
158                           - /var/lib/kolla/config_files/glance_api_tls_proxy.json:/var/lib/kolla/config_files/config.json:ro
159                           - /var/lib/config-data/puppet-generated/glance_api/:/var/lib/kolla/config_files/src:ro
160                           - /etc/pki/tls/certs/httpd:/etc/pki/tls/certs/httpd:ro
161                           - /etc/pki/tls/private/httpd:/etc/pki/tls/private/httpd:ro
162                     environment:
163                       - KOLLA_CONFIG_STRATEGY=COPY_ALWAYS
164                 - {}
165       host_prep_tasks:
166         - name: create persistent logs directory
167           file:
168             path: /var/log/containers/glance
169             state: directory
170         - name: ensure ceph configurations exist
171           file:
172             path: /etc/ceph
173             state: directory
174       upgrade_tasks:
175         - name: Stop and disable glance_api service
176           tags: step2
177           service: name=openstack-glance-api state=stopped enabled=no
178       metadata_settings:
179         get_attr: [GlanceApiPuppetBase, role_data, metadata_settings]