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