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