8f4a2014aabde5b08f11e5924097141f56c08e31
[apex-tripleo-heat-templates.git] / docker / services / keystone.yaml
1 heat_template_version: pike
2
3 description: >
4   OpenStack containerized Keystone service
5
6 parameters:
7   DockerKeystoneImage:
8     description: image
9     type: string
10   DockerKeystoneConfigImage:
11     description: The container image to use for the keystone 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   AdminPassword:
40     description: The password for the keystone admin account, used for monitoring, querying neutron etc.
41     type: string
42     hidden: true
43   KeystoneTokenProvider:
44     description: The keystone token format
45     type: string
46     default: 'fernet'
47     constraints:
48       - allowed_values: ['uuid', 'fernet']
49   EnableInternalTLS:
50     type: boolean
51     default: false
52
53 resources:
54
55   ContainersCommon:
56     type: ./containers-common.yaml
57
58   MySQLClient:
59     type: ../../puppet/services/database/mysql-client.yaml
60
61   KeystoneBase:
62     type: ../../puppet/services/keystone.yaml
63     properties:
64       EndpointMap: {get_param: EndpointMap}
65       ServiceData: {get_param: ServiceData}
66       ServiceNetMap: {get_param: ServiceNetMap}
67       DefaultPasswords: {get_param: DefaultPasswords}
68       RoleName: {get_param: RoleName}
69       RoleParameters: {get_param: RoleParameters}
70
71 conditions:
72
73   internal_tls_enabled: {equals: [{get_param: EnableInternalTLS}, true]}
74
75 outputs:
76   role_data:
77     description: Role data for the Keystone API role.
78     value:
79       service_name: {get_attr: [KeystoneBase, role_data, service_name]}
80       config_settings:
81         map_merge:
82           - get_attr: [KeystoneBase, role_data, config_settings]
83           - apache::default_vhost: false
84       step_config: &step_config
85         list_join:
86           - "\n"
87           - - "['Keystone_user', 'Keystone_endpoint', 'Keystone_domain', 'Keystone_tenant', 'Keystone_user_role', 'Keystone_role', 'Keystone_service'].each |String $val| { noop_resource($val) }"
88             - {get_attr: [KeystoneBase, role_data, step_config]}
89             - {get_attr: [MySQLClient, role_data, step_config]}
90       service_config_settings: {get_attr: [KeystoneBase, role_data, service_config_settings]}
91       # BEGIN DOCKER SETTINGS
92       puppet_config:
93         config_volume: keystone
94         puppet_tags: keystone_config
95         step_config: *step_config
96         config_image: &keystone_config_image {get_param: DockerKeystoneConfigImage}
97       kolla_config:
98         /var/lib/kolla/config_files/keystone.json:
99           command: /usr/sbin/httpd -DFOREGROUND
100           config_files:
101             - source: "/var/lib/kolla/config_files/src/*"
102               dest: "/"
103               merge: true
104               preserve_properties: true
105         /var/lib/kolla/config_files/keystone_cron.json:
106           # FIXME(dprince): this is unused ATM because Kolla hardcodes the
107           # args for the keystone container to -DFOREGROUND
108           command: /usr/sbin/crond -n
109           config_files:
110             - source: "/var/lib/kolla/config_files/src/*"
111               dest: "/"
112               merge: true
113               preserve_properties: true
114           permissions:
115             - path: /var/log/keystone
116               owner: keystone:keystone
117               recurse: true
118       docker_config:
119         # Kolla_bootstrap/db sync runs before permissions set by kolla_config
120         step_2:
121           keystone_init_log:
122             image: &keystone_image {get_param: DockerKeystoneImage}
123             user: root
124             command: ['/bin/bash', '-c', 'chown -R keystone:keystone /var/log/keystone']
125             volumes:
126               - /var/log/containers/keystone:/var/log/keystone
127               - /var/log/containers/httpd/keystone:/var/log/httpd
128         step_3:
129           keystone_db_sync:
130             image: *keystone_image
131             net: host
132             user: root
133             privileged: false
134             detach: false
135             volumes: &keystone_volumes
136               list_concat:
137                 - {get_attr: [ContainersCommon, volumes]}
138                 -
139                   - /var/lib/kolla/config_files/keystone.json:/var/lib/kolla/config_files/config.json:ro
140                   - /var/lib/config-data/puppet-generated/keystone/:/var/lib/kolla/config_files/src:ro
141                   - /var/log/containers/keystone:/var/log/keystone
142                   - /var/log/containers/httpd/keystone:/var/log/httpd
143                   -
144                     if:
145                       - internal_tls_enabled
146                       - /etc/pki/tls/certs/httpd:/etc/pki/tls/certs/httpd:ro
147                       - ''
148                   -
149                     if:
150                       - internal_tls_enabled
151                       - /etc/pki/tls/private/httpd:/etc/pki/tls/private/httpd:ro
152                       - ''
153             environment:
154               - KOLLA_BOOTSTRAP=True
155               - KOLLA_CONFIG_STRATEGY=COPY_ALWAYS
156             command: ['/usr/bin/bootstrap_host_exec', 'keystone', '/usr/local/bin/kolla_start']
157           keystone:
158             start_order: 2
159             image: *keystone_image
160             net: host
161             privileged: false
162             restart: always
163             volumes: *keystone_volumes
164             environment:
165               - KOLLA_CONFIG_STRATEGY=COPY_ALWAYS
166           keystone_bootstrap:
167             start_order: 3
168             action: exec
169             user: root
170             command:
171               [ 'keystone', '/usr/bin/bootstrap_host_exec', 'keystone' ,'keystone-manage', 'bootstrap', '--bootstrap-password', {get_param: AdminPassword} ]
172           keystone_cron:
173             start_order: 4
174             image: *keystone_image
175             user: root
176             net: host
177             privileged: false
178             restart: always
179             command: ['/bin/bash', '-c', '/usr/local/bin/kolla_set_configs && /usr/sbin/crond -n']
180             healthcheck:
181               test: /bin/true
182             volumes:
183               list_concat:
184                 - {get_attr: [ContainersCommon, volumes]}
185                 -
186                   - /var/lib/kolla/config_files/keystone_cron.json:/var/lib/kolla/config_files/config.json:ro
187                   - /var/lib/config-data/puppet-generated/keystone/:/var/lib/kolla/config_files/src:ro
188                   - /var/log/containers/keystone:/var/log/keystone
189                   - /var/log/containers/httpd/keystone:/var/log/httpd
190             environment:
191               - KOLLA_CONFIG_STRATEGY=COPY_ALWAYS
192       docker_puppet_tasks:
193         # Keystone endpoint creation occurs only on single node
194         step_3:
195           config_volume: 'keystone_init_tasks'
196           puppet_tags: 'keystone_config,keystone_domain_config,keystone_endpoint,keystone_identity_provider,keystone_paste_ini,keystone_role,keystone_service,keystone_tenant,keystone_user,keystone_user_role,keystone_domain'
197           step_config: 'include ::tripleo::profile::base::keystone'
198           config_image: *keystone_config_image
199       host_prep_tasks:
200         - name: create persistent logs directory
201           file:
202             path: "{{ item }}"
203             state: directory
204           with_items:
205             - /var/log/containers/keystone
206             - /var/log/containers/httpd/keystone
207       upgrade_tasks:
208         - name: Stop and disable keystone service (running under httpd)
209           tags: step2
210           service: name=httpd state=stopped enabled=no
211         - name: remove old keystone cron jobs
212           file:
213             path: /var/spool/cron/keystone
214             state: absent
215       metadata_settings:
216         get_attr: [KeystoneBase, role_data, metadata_settings]