-
Notifications
You must be signed in to change notification settings - Fork 0
/
keystone-ldap-prototype.yaml
481 lines (415 loc) · 16.5 KB
/
keystone-ldap-prototype.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
heat_template_version: 2013-05-23
description: >
This template will provision two keystone servers and two ldap servers.
This will demonstrate how to configure multi-region keystone.
parameters:
ldap_domain:
description: blah
type: string
default: "test.com"
constraints:
- allowed_pattern: "[a-zA-z]*.[a-zA-Z]*"
keystone_sha:
description: sha from which to clone keystone.
type: string
default: "7c2bee76936461043671adc6d100f20775c4212f"
resources:
ldap_admin_pass:
type: "OS::Heat::RandomString"
maria_admin_pass:
type: "OS::Heat::RandomString"
ldap:
type: "Rackspace::Cloud::Server"
properties:
flavor: 1 GB Performance
image: Ubuntu 14.04 LTS (Trusty Tahr)
key_name: shep
user_data:
str_replace:
template: |
#!/bin/bash
apt-get install -y debconf-utils
debconf-set-selections <<< 'slapd slapd/password1 password %ldap_admin_pass%'
debconf-set-selections <<< 'slapd slapd/password2 password %ldap_admin_pass%'
debconf-set-selections <<< 'slapd slapd/domain string %ldap_domain%'
debconf-set-selections <<< 'slapd slapd/backend select HDB'
debconf-set-selections <<< 'slapd slapd/purge_database boolean false'
debconf-set-selections <<< 'slapd slapd/move_old_database boolean true'
debconf-set-selections <<< 'slapd slapd/allow_ldap_v2 boolean false'
# Install openldap
apt-get install -y slapd ldap-utils
# Create tmp dir for ldif files
tmp_ldap_dir=$(mktemp -d -t ldap.$$.XXXXXXXXXX)
# Create slappasswd
export SLAPPASS=$(slappasswd -s %ldap_admin_pass%)
# Build out LDAP_BASE_DN from ldap_domain
export LDAP_BASE_DN=$(echo %ldap_domain% | awk -F '.' '{print "dc=" $1 ",dc=" $2}')
export LDAP_BASE_DC=$(echo %ldap_domain% | awk -F '.' '{print $1}')
export LDAP_MANAGER_DN="cn=Manager,${LDAP_BASE_DN}"
# drop a manager.ldif
tee ${tmp_ldap_dir}/manager.ldif <<EOF
dn: olcDatabase={1}hdb,cn=config
changetype: modify
replace: olcSuffix
olcSuffix: $LDAP_BASE_DN
-
replace: olcRootDN
olcRootDN: ${LDAP_MANAGER_DN}
-
replace: olcRootPW
olcRootPW: ${SLAPPASS}
-
replace: olcDbIndex
olcDbIndex: objectClass eq
olcDbIndex: default pres,eq
olcDbIndex: cn,sn,givenName
EOF
# upload manager.ldif
ldapmodify -Y EXTERNAL -H ldapi:/// -f ${tmp_ldap_dir}/manager.ldif
# configure logging
mkdir /var/log/slapd
chmod 755 /var/log/slapd
chown openldap:openldap /var/log/slapd
tee ${tmp_ldap_dir}/logging.ldif <<EOF
dn: cn=config
changetype: modify
replace: olcLogFile
olcLogFile: /var/log/slapd/slapd.log
-
replace: olcLogLevel
olcLogLevel: conns filter config acl stats shell
EOF
# upload manager.ldif
ldapmodify -Y EXTERNAL -H ldapi:/// -f ${tmp_ldap_dir}/logging.ldif
service slapd restart
# drop a keystone.ldif
tee ${tmp_ldap_dir}/keystone.ldif <<EOF
#dn: ${LDAP_BASE_DN}
#objectClass: dcObject
#objectClass: organizationalUnit
#dc: ${LDAP_BASE_DC}
#ou: ${LDAP_BASE_DC}
# NOTE(galstrom): Do not confuse with 'groups' in keystone
dn: ou=Groups,${LDAP_BASE_DN}
objectClass: organizationalUnit
ou: UserGroups
dn: ou=Users,${LDAP_BASE_DN}
objectClass: organizationalUnit
ou: Users
dn: ou=Roles,${LDAP_BASE_DN}
objectClass: organizationalUnit
ou: Roles
dn: ou=Projects,${LDAP_BASE_DN}
objectClass: organizationalUnit
ou: Projects
dn: cn=9fe2ff9ee4384b1894a90878d3e92bab,ou=Roles,${LDAP_BASE_DN}
objectClass: organizationalRole
ou: _member_
cn: 9fe2ff9ee4384b1894a90878d3e92bab
# BEGIN EXAMPLE USERS HERE #
dn: uid=admin,ou=Users,${LDAP_BASE_DN}
objectClass: person
objectClass: inetOrgPerson
cn: Admin
uid: admin
sn: User
userPassword: secrete
dn: uid=jsmith,ou=Users,${LDAP_BASE_DN}
objectClass: person
objectClass: inetOrgPerson
cn: James Smith
uid: jsmith
sn: Smith
userPassword: password
dn: uid=rjohnson,ou=Users,${LDAP_BASE_DN}
objectClass: person
objectClass: inetOrgPerson
cn: Robert Johnson
uid: rjohnson
sn: Johnson
userPassword: password
dn: uid=jwilliams,ou=Users,${LDAP_BASE_DN}
objectClass: person
objectClass: inetOrgPerson
cn: John Williams
uid: jwilliams
sn: Williams
userPassword: password
dn: uid=mbrown,ou=Users,${LDAP_BASE_DN}
objectClass: person
objectClass: inetOrgPerson
cn: Michael Brown
uid: mbrown
sn: Brown
userPassword: password
dn: uid=wjones,ou=Users,${LDAP_BASE_DN}
objectClass: person
objectClass: inetOrgPerson
cn: William Jones
uid: wjones
sn: Jones
userPassword: password
dn: uid=dmiller,ou=Users,${LDAP_BASE_DN}
objectClass: person
objectClass: inetOrgPerson
cn: David Miller
uid: dmiller
sn: Miller
userPassword: password
dn: uid=rdavis,ou=Users,${LDAP_BASE_DN}
objectClass: person
objectClass: inetOrgPerson
cn: Richard Davis
uid: rdavis
sn: Davis
userPassword: password
dn: uid=cwilson,ou=Users,${LDAP_BASE_DN}
objectClass: person
objectClass: inetOrgPerson
cn: Charles Wilson
uid: cwilson
sn: Wilson
userPassword: password
dn: uid=jmartinez,ou=Users,${LDAP_BASE_DN}
objectClass: person
objectClass: inetOrgPerson
cn: Joseph Martinez
uid: jmartinez
sn: Martinez
userPassword: password
dn: uid=tanderson,ou=Users,${LDAP_BASE_DN}
objectClass: person
objectClass: inetOrgPerson
cn: Thomas Anderson
uid: tanderson
sn: Anderson
userPassword: password
dn: uid=ctaylor,ou=Users,${LDAP_BASE_DN}
objectClass: person
objectClass: inetOrgPerson
cn: Christopher Taylor
uid: ctaylor
sn: Taylor
userPassword: password
dn: uid=dthomas,ou=Users,${LDAP_BASE_DN}
objectClass: person
objectClass: inetOrgPerson
cn: Daniel Thomas
uid: dthomas
sn: Thomas
userPassword: password
dn: uid=phernandez,ou=Users,${LDAP_BASE_DN}
objectClass: person
objectClass: inetOrgPerson
cn: Paul Hernandez
uid: phernandez
sn: Hernandez
userPassword: password
dn: uid=mmoore,ou=Users,${LDAP_BASE_DN}
objectClass: person
objectClass: inetOrgPerson
cn: Mark Moore
uid: mmoore
sn: Moore
userPassword: password
dn: uid=dmartin,ou=Users,${LDAP_BASE_DN}
objectClass: person
objectClass: inetOrgPerson
cn: Donald Martin
uid: dmartin
sn: Martin
userPassword: password
dn: uid=gjackson,ou=Users,${LDAP_BASE_DN}
objectClass: person
objectClass: inetOrgPerson
cn: George Jackson
uid: gjackson
sn: Jackson
userPassword: password
dn: uid=kthompson,ou=Users,${LDAP_BASE_DN}
objectClass: person
objectClass: inetOrgPerson
cn: Kenneth Thompson
uid: kthompson
sn: Thompson
userPassword: password
dn: uid=swhite,ou=Users,${LDAP_BASE_DN}
objectClass: person
objectClass: inetOrgPerson
cn: Steven White
uid: swhite
sn: White
userPassword: password
# END EXAMPLE USERS HERE #
# BEGIN EXAMPLE GROUPS HERE #
dn: cn=engineering,ou=Groups,${LDAP_BASE_DN}
cn: Engineering Group
objectClass: groupOfNames
member: uid=jsmith,ou=Users,${LDAP_BASE_DN}
member: uid=rjohnson,ou=Users,${LDAP_BASE_DN}
member: uid=jwilliams,ou=Users,${LDAP_BASE_DN}
member: uid=mbrown,ou=Users,${LDAP_BASE_DN}
member: uid=wjones,ou=Users,${LDAP_BASE_DN}
dn: cn=developmet,ou=Groups,${LDAP_BASE_DN}
cn: Development Group
objectClass: groupOfNames
member: uid=dmiller,ou=Users,${LDAP_BASE_DN}
member: uid=rdavis,ou=Users,${LDAP_BASE_DN}
member: uid=cwilson,ou=Users,${LDAP_BASE_DN}
member: uid=jmartinez,ou=Users,${LDAP_BASE_DN}
member: uid=tanderson,ou=Users,${LDAP_BASE_DN}
dn: cn=sales,ou=Groups,${LDAP_BASE_DN}
cn: Salses Group
objectClass: groupOfNames
member: uid=ctaylor,ou=Users,${LDAP_BASE_DN}
member: uid=dthomas,ou=Users,${LDAP_BASE_DN}
member: uid=phernandez,ou=Users,${LDAP_BASE_DN}
member: uid=mmoore,ou=Users,${LDAP_BASE_DN}
member: uid=dmartin,ou=Users,${LDAP_BASE_DN}
dn: cn=marketing,ou=Groups,${LDAP_BASE_DN}
cn: Marketing Group
objectClass: groupOfNames
member: uid=gjackson,ou=Users,${LDAP_BASE_DN}
member: uid=kthompson,ou=Users,${LDAP_BASE_DN}
member: uid=swhite,ou=Users,${LDAP_BASE_DN}
# END EXAMPLE GROUPS HERE #
EOF
# upload keystone.ldif
ldapadd -x -w %ldap_admin_pass% -D $LDAP_MANAGER_DN -H ldap://localhost -c -f ${tmp_ldap_dir}/keystone.ldif
params:
"%ldap_admin_pass%": { get_attr: [ldap_admin_pass, value] }
"%ldap_domain%": { get_param: ldap_domain }
keystone:
type: "Rackspace::Cloud::Server"
properties:
flavor: 1 GB Performance
image: Ubuntu 14.04 LTS (Trusty Tahr)
key_name: shep
user_data:
str_replace:
template: |
#!/bin/bash
apt-get install -y debconf-utils screen git libxml2-dev libxslt1-dev zlib1g-dev libldap2-dev libsasl2-dev libssl-dev
# Install MariaDB
debconf-set-selections <<< 'mariadb-server-5.5 mysql-server/root_password password %maria_admin_passwd%'
debconf-set-selections <<< 'mariadb-server-5.5 mysql-server/root_password_again password %maria_admin_passwd%'
debconf-set-selections <<< 'mariadb-server-5.5 mariadb-server/oneway_migration boolean true'
apt-get install -y mariadb-server-5.5 libmysqlclient-dev
mysql -u root -p%maria_admin_passwd% -e "GRANT ALL PRIVILEGES ON keystone.* TO 'keystone'@'%' IDENTIFIED BY 'keystonepass'"
mysql -u root -p%maria_admin_passwd% -e "create database keystone"
# Checkout keystone
cd /opt
git clone https://github.com/openstack/keystone
pushd /opt/keystone
git checkout %keystone_sha%
# Install all python dependencies
pip install -r requirements.txt
cat test-requirements.txt | grep ldap | xargs pip install
pip install tempita decorator sqlparse MySQL-python
# Configure keystone.conf
pushd etc/
tee keystone.conf <<EOF
[DEFAULT]
admin_token=ADMIN
admin_port=35357
public_port=5000
member_role_id=9fe2ff9ee4384b1894a90878d3e92bab
member_role_name=_member_
[assignment]
driver=keystone.assignment.backends.sql.Assignment
[auth]
#
# Options defined in keystone
#
# Default auth methods. (list value)
#methods=external,password,token
# The password auth plugin module. (string value)
#password=keystone.auth.plugins.password.Password
# The token auth plugin module. (string value)
#token=keystone.auth.plugins.token.Token
# The external (REMOTE_USER) auth plugin module. (string
# value)
#external=keystone.auth.plugins.external.DefaultDomain
[catalog]
#driver=keystone.catalog.backends.sql.Catalog
[credential]
#driver=keystone.credential.backends.sql.Credential
[database]
connection=mysql://keystone:[email protected]/keystone
[ec2]
#driver=keystone.contrib.ec2.backends.kvs.Ec2
[endpoint_filter]
#driver=keystone.contrib.endpoint_filter.backends.sql.EndpointFilter
[federation]
#driver=keystone.contrib.federation.backends.sql.Federation
[identity]
driver=keystone.identity.backends.ldap.Identity
[ldap]
debug_level=4095
url=ldap://%ldap_url%
user=cn=Manager,dc=test,dc=com
password=%ldap_admin_pass%
suffix=dc=test,dc=com
#use_dumb_member=true
use_dumb_member=False
# User attributes
user_tree_dn=ou=Users,dc=test,dc=com
user_objectClass=inetOrgPerson
user_id_attribute=uid
user_name_attribute=uid
user_pass_attribute=userPassword
#user_attribute_ignore=enabled,email,tenants,default_project_id
# Make it read-only
user_allow_create=False
user_allow_update=False
user_allow_delete=False
# tenant attributes
#tenant_tree_dn=ou=Projects,dc=test,dc=com
#tenant_desc_attribute=description
#tenant_attribute_ignore=enabled
# Make it read-only
tenant_allow_create=False
tenant_allow_update=False
tenant_allow_delete=False
# role attributes
# Make it read-only
role_allow_create=False
role_allow_update=False
role_allow_delete=False
[oauth1]
#driver=keystone.contrib.oauth1.backends.sql.OAuth1
[policy]
driver=keystone.policy.backends.sql.Policy
[token]
provider=keystone.token.providers.uuid.Provider
EOF
popd
# sync the keystone database
bin/keystone-manage db_sync
screen -d -m bin/keystone-all
# sleep for 1/3 of a shep
sleep 10s
popd
# Bootstrap the admin user
OPTS="--os-endpoint http://0.0.0.0:35357/v2.0 --os-token ADMIN"
keystone $OPTS tenant-create --name admin
keystone $OPTS role-create --name admin
keystone $OPTS user-role-add --user admin --tenant admin --role admin
# Configure keystone endpoint
MYIP=$(ifconfig $(route -n | grep '^0.0.0.0' | awk '{print $8}') | { IFS=' :';read r; read r r a r; echo $a; } )
OPTS="--os-endpoint http://0.0.0.0:35357/v2.0 --os-token ADMIN"
keystone $OPTS service-create --name keystone --type identity
keystone $OPTS endpoint-create --region RegionOne --service keystone \
--publicurl http://$MYIP:5000/v2.0 \
--adminurl http://$MYIP:35357/v2.0 \
--internalurl http://$MYIP:5000/v2.0
params:
"%keystone_sha%": { get_param: keystone_sha }
"%maria_admin_passwd%": { get_attr: [maria_admin_pass, value ]}
"%ldap_admin_pass%": { get_attr: [ldap_admin_pass, value] }
"%ldap_url%": { get_attr: [ldap, privateIPv4] }
outputs:
ldap_admin_pass:
value: { get_attr: [ldap_admin_pass, value] }
maria_admin_pass:
value: { get_attr: [maria_admin_pass, value ] }