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