Merge "Set docker-puppet --health-cmd = /bin/true" 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       step_config: &step_config
82         list_join:
83           - "\n"
84           - - {get_attr: [GlanceApiPuppetBase, role_data, step_config]}
85             - {get_attr: [MySQLClient, role_data, step_config]}
86       service_config_settings: {get_attr: [GlanceApiPuppetBase, role_data, service_config_settings]}
87       # BEGIN DOCKER SETTINGS #
88       puppet_config:
89         config_volume: glance_api
90         puppet_tags: glance_api_config,glance_api_paste_ini,glance_swift_config,glance_cache_config
91         step_config: *step_config
92         config_image: {get_param: DockerGlanceApiConfigImage}
93       kolla_config:
94         /var/lib/kolla/config_files/glance_api.json:
95           command: /usr/bin/glance-api --config-file /usr/share/glance/glance-api-dist.conf --config-file /etc/glance/glance-api.conf
96           config_files:
97             - source: "/var/lib/kolla/config_files/src/*"
98               dest: "/"
99               merge: true
100               preserve_properties: true
101             - source: "/var/lib/kolla/config_files/src-ceph/"
102               dest: "/etc/ceph/"
103               merge: true
104               preserve_properties: true
105         /var/lib/kolla/config_files/glance_api_tls_proxy.json:
106           command: /usr/sbin/httpd -DFOREGROUND
107           config_files:
108             - source: "/var/lib/kolla/config_files/src/*"
109               dest: "/"
110               merge: true
111               preserve_properties: true
112       docker_config:
113         # Kolla_bootstrap/db_sync runs before permissions set by kolla_config
114         step_2:
115           glance_init_logs:
116             image: &glance_api_image {get_param: DockerGlanceApiImage}
117             privileged: false
118             user: root
119             volumes:
120               - /var/log/containers/glance:/var/log/glance
121             command: ['/bin/bash', '-c', 'chown -R glance:glance /var/log/glance']
122         step_3:
123           glance_api_db_sync:
124             image: *glance_api_image
125             net: host
126             privileged: false
127             detach: false
128             user: root
129             volumes: &glance_volumes
130               list_concat:
131                 - {get_attr: [ContainersCommon, volumes]}
132                 -
133                   - /var/lib/kolla/config_files/glance_api.json:/var/lib/kolla/config_files/config.json
134                   - /var/lib/config-data/puppet-generated/glance_api/:/var/lib/kolla/config_files/src:ro
135                   - /var/log/containers/glance:/var/log/glance
136                   - /etc/ceph:/var/lib/kolla/config_files/src-ceph:ro
137                   -
138                     if:
139                       - nfs_backend_enabled
140                       - /var/lib/glance:/var/lib/glance
141                       - ''
142             environment:
143               - KOLLA_BOOTSTRAP=True
144               - KOLLA_CONFIG_STRATEGY=COPY_ALWAYS
145             command: "/usr/bin/bootstrap_host_exec glance_api su glance -s /bin/bash -c '/usr/local/bin/kolla_start'"
146         step_4:
147           map_merge:
148             - glance_api:
149                 start_order: 2
150                 image: *glance_api_image
151                 net: host
152                 privileged: false
153                 restart: always
154                 volumes: *glance_volumes
155                 environment:
156                   - KOLLA_CONFIG_STRATEGY=COPY_ALWAYS
157             - if:
158                 - internal_tls_enabled
159                 - glance_api_tls_proxy:
160                     start_order: 2
161                     image: *glance_api_image
162                     net: host
163                     user: root
164                     restart: always
165                     volumes:
166                       list_concat:
167                         - {get_attr: [ContainersCommon, volumes]}
168                         -
169                           - /var/lib/kolla/config_files/glance_api_tls_proxy.json:/var/lib/kolla/config_files/config.json:ro
170                           - /var/lib/config-data/puppet-generated/glance_api/:/var/lib/kolla/config_files/src:ro
171                           - /etc/pki/tls/certs/httpd:/etc/pki/tls/certs/httpd:ro
172                           - /etc/pki/tls/private/httpd:/etc/pki/tls/private/httpd:ro
173                     environment:
174                       - KOLLA_CONFIG_STRATEGY=COPY_ALWAYS
175                 - {}
176       host_prep_tasks:
177         - name: create persistent logs directory
178           file:
179             path: /var/log/containers/glance
180             state: directory
181         - name: ensure ceph configurations exist
182           file:
183             path: /etc/ceph
184             state: directory
185       upgrade_tasks:
186         - name: Stop and disable glance_api service
187           tags: step2
188           service: name=openstack-glance-api state=stopped enabled=no
189       metadata_settings:
190         get_attr: [GlanceApiPuppetBase, role_data, metadata_settings]