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