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