17d911071f663448609d0fd7d6ddefdafeb007d2
[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   DockerNamespace:
8     description: namespace
9     default: 'tripleoupstream'
10     type: string
11   DockerGlanceApiImage:
12     description: image
13     default: 'centos-binary-glance-api:latest'
14     type: string
15   DockerGlanceApiConfigImage:
16     description: The container image to use for the glance_api config_volume
17     default: 'centos-binary-glance-api:latest'
18     type: string
19   EndpointMap:
20     default: {}
21     description: Mapping of service endpoint -> protocol. Typically set
22                  via parameter_defaults in the resource registry.
23     type: json
24   ServiceNetMap:
25     default: {}
26     description: Mapping of service_name -> network name. Typically set
27                  via parameter_defaults in the resource registry.  This
28                  mapping overrides those in ServiceNetMapDefaults.
29     type: json
30   DefaultPasswords:
31     default: {}
32     type: json
33   RoleName:
34     default: ''
35     description: Role name on which the service is applied
36     type: string
37   RoleParameters:
38     default: {}
39     description: Parameters specific to the role
40     type: json
41   EnableInternalTLS:
42     type: boolean
43     default: false
44
45 conditions:
46
47   internal_tls_enabled: {equals: [{get_param: EnableInternalTLS}, true]}
48
49
50 resources:
51
52   ContainersCommon:
53     type: ./containers-common.yaml
54
55   GlanceApiPuppetBase:
56     type: ../../puppet/services/glance-api.yaml
57     properties:
58       EndpointMap: {get_param: EndpointMap}
59       ServiceNetMap: {get_param: ServiceNetMap}
60       DefaultPasswords: {get_param: DefaultPasswords}
61       RoleName: {get_param: RoleName}
62       RoleParameters: {get_param: RoleParameters}
63
64 outputs:
65   role_data:
66     description: Role data for the Glance API role.
67     value:
68       service_name: {get_attr: [GlanceApiPuppetBase, role_data, service_name]}
69       config_settings:
70         map_merge:
71           - get_attr: [GlanceApiPuppetBase, role_data, config_settings]
72           - glance::api::sync_db: false
73       step_config: &step_config
74         get_attr: [GlanceApiPuppetBase, role_data, step_config]
75       service_config_settings: {get_attr: [GlanceApiPuppetBase, role_data, service_config_settings]}
76       # BEGIN DOCKER SETTINGS #
77       puppet_config:
78         config_volume: glance_api
79         puppet_tags: glance_api_config,glance_api_paste_ini,glance_swift_config,glance_cache_config
80         step_config: *step_config
81         config_image:
82           list_join:
83             - '/'
84             - [ {get_param: DockerNamespace}, {get_param: DockerGlanceApiConfigImage} ]
85       kolla_config:
86         /var/lib/kolla/config_files/glance_api.json:
87           command: /usr/bin/glance-api --config-file /usr/share/glance/glance-api-dist.conf --config-file /etc/glance/glance-api.conf
88           config_files:
89             - source: "/var/lib/kolla/config_files/src/*"
90               dest: "/"
91               merge: true
92               preserve_properties: true
93         /var/lib/kolla/config_files/glance_api_tls_proxy.json:
94           command: /usr/sbin/httpd -DFOREGROUND
95           config_files:
96             - source: "/var/lib/kolla/config_files/src/*"
97               dest: "/"
98               merge: true
99               preserve_properties: true
100       docker_config:
101         # Kolla_bootstrap/db_sync runs before permissions set by kolla_config
102         step_2:
103           glance_init_logs:
104             image: &glance_api_image
105               list_join:
106                 - '/'
107                 - [ {get_param: DockerNamespace}, {get_param: DockerGlanceApiImage} ]
108             privileged: false
109             user: root
110             volumes:
111               - /var/log/containers/glance:/var/log/glance
112             command: ['/bin/bash', '-c', 'chown -R glance:glance /var/log/glance']
113         step_3:
114           glance_api_db_sync:
115             image: *glance_api_image
116             net: host
117             privileged: false
118             detach: false
119             user: root
120             volumes: &glance_volumes
121               list_concat:
122                 - {get_attr: [ContainersCommon, volumes]}
123                 -
124                   - /var/lib/kolla/config_files/glance_api.json:/var/lib/kolla/config_files/config.json
125                   - /var/lib/config-data/puppet-generated/glance_api/:/var/lib/kolla/config_files/src:ro
126                   - /var/log/containers/glance:/var/log/glance
127             environment:
128               - KOLLA_BOOTSTRAP=True
129               - KOLLA_CONFIG_STRATEGY=COPY_ALWAYS
130             command: "/usr/bin/bootstrap_host_exec glance_api su glance -s /bin/bash -c '/usr/local/bin/kolla_start'"
131         step_4:
132           map_merge:
133             - glance_api:
134                 start_order: 2
135                 image: *glance_api_image
136                 net: host
137                 privileged: false
138                 restart: always
139                 volumes: *glance_volumes
140                 environment:
141                   - KOLLA_CONFIG_STRATEGY=COPY_ALWAYS
142             - if:
143                 - internal_tls_enabled
144                 - glance_api_tls_proxy:
145                     start_order: 2
146                     image: *glance_api_image
147                     net: host
148                     user: root
149                     restart: always
150                     volumes:
151                       list_concat:
152                         - {get_attr: [ContainersCommon, volumes]}
153                         -
154                           - /var/lib/kolla/config_files/glance_api_tls_proxy.json:/var/lib/kolla/config_files/config.json:ro
155                           - /var/lib/config-data/puppet-generated/glance_api/:/var/lib/kolla/config_files/src:ro
156                           - /etc/pki/tls/certs/httpd:/etc/pki/tls/certs/httpd:ro
157                           - /etc/pki/tls/private/httpd:/etc/pki/tls/private/httpd:ro
158                     environment:
159                       - KOLLA_CONFIG_STRATEGY=COPY_ALWAYS
160                 - {}
161       host_prep_tasks:
162         - name: create persistent logs directory
163           file:
164             path: /var/log/containers/glance
165             state: directory
166       upgrade_tasks:
167         - name: Stop and disable glance_api service
168           tags: step2
169           service: name=openstack-glance-api state=stopped enabled=no
170       metadata_settings:
171         get_attr: [GlanceApiPuppetBase, role_data, metadata_settings]