blob: e6f3b6c3ddf9f5701e7759ffa64f72d1f7dc5fc3 [file] [log] [blame]
Jackie Huang57fdea72020-04-23 11:29:15 +08001#
2## Copyright (C) 2019 Wind River Systems, Inc.
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15
16DESCRIPTION = "Authentication service for OpenStack"
17HOMEPAGE = "http://www.openstack.org"
18SECTION = "devel/python"
19LICENSE = "Apache-2.0"
20LIC_FILES_CHKSUM = "file://LICENSE;md5=1dece7821bf3fd70fe1309eaa37d52a2"
21
22SRCREV = "c78581b4608f3dc10e945d358963000f284f188a"
23SRCNAME = "keystone"
24PROTOCOL = "git"
25BRANCH = "stable/stein"
26S = "${WORKDIR}/git"
27PV = "15.0.0+git${SRCPV}"
28
29
30SRC_URI = " \
31 git://opendev.org/openstack/${SRCNAME}.git;protocol=${PROTOCOL};branch=${BRANCH} \
32 file://${PN}/keystone.conf \
33 file://${PN}/identity.sh \
34 file://${PN}/convert_keystone_backend.py \
35 file://${PN}/wsgi-keystone.conf \
36 file://${PN}/admin-openrc \
37 file://${PN}/keystone-init.service \
38 file://${PN}/stx-files/openstack-keystone.service \
39 file://${PN}/stx-files/keystone-all \
40 file://${PN}/stx-files/keystone-fernet-keys-rotate-active \
41 file://${PN}/stx-files/public.py \
42 file://${PN}/stx-files/password-rules.conf \
43 "
44
45
46inherit setuptools identity hosts default_configs monitor useradd systemd
47
48SERVICE_TOKEN = "password"
49TOKEN_FORMAT ?= "PKI"
50
51USERADD_PACKAGES = "${PN}"
52USERADD_PARAM_${PN} = "--system -m -s /bin/false keystone"
53
54LDAP_DN ?= "dc=my-domain,dc=com"
55
56SERVICECREATE_PACKAGES = "${SRCNAME}-setup"
57KEYSTONE_HOST="${CONTROLLER_IP}"
58
59# USERCREATE_PARAM and SERVICECREATE_PARAM contain the list of parameters to be
60# set. If the flag for a parameter in the list is not set here, the default
61# value will be given to that parameter. Parameters not in the list will be set
62# to empty.
63
64USERCREATE_PARAM_${SRCNAME}-setup = "name pass tenant role email"
65python () {
66 flags = {'name':'${ADMIN_USER}',\
67 'pass':'${ADMIN_PASSWORD}',\
68 'tenant':'${ADMIN_TENANT}',\
69 'role':'${ADMIN_ROLE}',\
70 'email':'${ADMIN_USER_EMAIL}',\
71 }
72 d.setVarFlags("USERCREATE_PARAM_%s-setup" % d.getVar('SRCNAME',True), flags)
73}
74
75SERVICECREATE_PARAM_${SRCNAME}-setup = "name type description region publicurl adminurl internalurl"
76python () {
77 flags = {'type':'identity',\
78 'description':'OpenStack Identity',\
79 'publicurl':"'http://${KEYSTONE_HOST}:8081/keystone/main/v2.0'",\
80 'adminurl':"'http://${KEYSTONE_HOST}:8081/keystone/admin/v2.0'",\
81 'internalurl':"'http://${KEYSTONE_HOST}:8081/keystone/main/v2.0'"}
82 d.setVarFlags("SERVICECREATE_PARAM_%s-setup" % d.getVar('SRCNAME',True), flags)
83}
84
85do_install_append() {
86
87 KEYSTONE_CONF_DIR=${D}${sysconfdir}/keystone
88 KEYSTONE_DATA_DIR=${D}${localstatedir}/lib/keystone
89 KEYSTONE_PACKAGE_DIR=${D}${PYTHON_SITEPACKAGES_DIR}/keystone
90 APACHE_CONF_DIR=${D}${sysconfdir}/apache2/conf.d/
91
92
93 # Create directories
94 install -m 755 -d ${KEYSTONE_CONF_DIR}
95 install -m 755 -d ${KEYSTONE_DATA_DIR}
96 install -m 755 -d ${APACHE_CONF_DIR}
97 install -d ${D}${localstatedir}/log/${SRCNAME}
98
99 # Setup the systemd service file
100 install -d ${D}${systemd_system_unitdir}/
101 install -m 644 ${WORKDIR}/${PN}/keystone-init.service ${D}${systemd_system_unitdir}/keystone-init.service
102
103 mv ${D}/${datadir}/etc/keystone/sso_callback_template.html ${KEYSTONE_CONF_DIR}/
104 rm -rf ${D}/${datadir}
105
106 # Setup the admin-openrc file
107 KS_OPENRC_FILE=${KEYSTONE_CONF_DIR}/admin-openrc
108 install -m 600 ${WORKDIR}/${PN}/admin-openrc ${KS_OPENRC_FILE}
109 sed -e "s:%CONTROLLER_IP%:${CONTROLLER_IP}:g" -i ${KS_OPENRC_FILE}
110 sed -e "s:%ADMIN_USER%:${ADMIN_USER}:g" -i ${KS_OPENRC_FILE}
111 sed -e "s:%ADMIN_PASSWORD%:${ADMIN_PASSWORD}:g" -i ${KS_OPENRC_FILE}
112
113 # Install various configuration files. We have to select suitable
114 # permissions as packages such as Apache require read access.
115 #
116 # Apache needs to read the keystone.conf
117 install -m 644 ${WORKDIR}/${PN}/keystone.conf ${KEYSTONE_CONF_DIR}/
118 # Apache needs to read the wsgi-keystone.conf
119 install -m 644 ${WORKDIR}/${PN}/wsgi-keystone.conf ${APACHE_CONF_DIR}/keystone.conf
120 install -m 600 ${S}${sysconfdir}/logging.conf.sample ${KEYSTONE_CONF_DIR}/logging.conf
121
122 # Copy examples from upstream
123 cp -r ${S}/examples ${KEYSTONE_PACKAGE_DIR}
124
125 # Edit the configuration to allow it to work out of the box
126 KEYSTONE_CONF_FILE=${KEYSTONE_CONF_DIR}/keystone.conf
127 sed "/# admin_endpoint = .*/a \
128 public_endpoint = http://%CONTROLLER_IP%:5000/ " \
129 -i ${KEYSTONE_CONF_FILE}
130
131 sed "/# admin_endpoint = .*/a \
132 admin_endpoint = http://%CONTROLLER_IP%:35357/ " \
133 -i ${KEYSTONE_CONF_FILE}
134
135 sed -e "s:%SERVICE_TOKEN%:${SERVICE_TOKEN}:g" -i ${KEYSTONE_CONF_FILE}
136 sed -e "s:%DB_USER%:${DB_USER}:g" -i ${KEYSTONE_CONF_FILE}
137 sed -e "s:%DB_PASSWORD%:${DB_PASSWORD}:g" -i ${KEYSTONE_CONF_FILE}
138 sed -e "s:%CONTROLLER_IP%:${CONTROLLER_IP}:g" -i ${KEYSTONE_CONF_FILE}
139 sed -e "s:%CONTROLLER_IP%:${CONTROLLER_IP}:g" -i ${KEYSTONE_CONF_FILE}
140 sed -e "s:%TOKEN_FORMAT%:${TOKEN_FORMAT}:g" -i ${KEYSTONE_CONF_FILE}
141
142 install -d ${KEYSTONE_PACKAGE_DIR}/tests/tmp
143 if [ -e "${KEYSTONE_PACKAGE_DIR}/tests/test_overrides.conf" ];then
144 sed -e "s:%KEYSTONE_PACKAGE_DIR%:${PYTHON_SITEPACKAGES_DIR}/keystone:g" \
145 -i ${KEYSTONE_PACKAGE_DIR}/tests/test_overrides.conf
146 fi
147
148 if ${@bb.utils.contains('DISTRO_FEATURES', 'OpenLDAP', 'true', 'false', d)};
149 then
150 sed -i -e '/^\[identity\]/a \
151driver = keystone.identity.backends.hybrid_identity.Identity \
152\
153[assignment]\
154driver = keystone.assignment.backends.hybrid_assignment.Assignment\
155' ${D}${sysconfdir}/keystone/keystone.conf
156
157 sed -i -e '/^\[ldap\]/a \
158url = ldap://localhost \
159user = cn=Manager,${LDAP_DN} \
160password = secret \
161suffix = ${LDAP_DN} \
162use_dumb_member = True \
163\
164user_tree_dn = ou=Users,${LDAP_DN} \
165user_attribute_ignore = enabled,email,tenants,default_project_id \
166user_id_attribute = uid \
167user_name_attribute = uid \
168user_mail_attribute = email \
169user_pass_attribute = keystonePassword \
170\
171tenant_tree_dn = ou=Groups,${LDAP_DN} \
172tenant_desc_attribute = description \
173tenant_domain_id_attribute = businessCategory \
174tenant_attribute_ignore = enabled \
175tenant_objectclass = groupOfNames \
176tenant_id_attribute = cn \
177tenant_member_attribute = member \
178tenant_name_attribute = ou \
179\
180role_attribute_ignore = enabled \
181role_objectclass = groupOfNames \
182role_member_attribute = member \
183role_id_attribute = cn \
184role_name_attribute = ou \
185role_tree_dn = ou=Roles,${LDAP_DN} \
186' ${KEYSTONE_CONF_FILE}
187
188 install -m 0755 ${WORKDIR}/${PN}/convert_keystone_backend.py \
189 ${D}${sysconfdir}/keystone/convert_keystone_backend.py
190 fi
191
192
193 install -m 755 ${WORKDIR}/${PN}/stx-files/keystone-fernet-keys-rotate-active ${D}/${bindir}/keystone-fernet-keys-rotate-active
194 install -m 440 ${WORKDIR}/${PN}/stx-files/password-rules.conf ${KEYSTONE_CONF_DIR}/password-rules.conf
195 install -m 755 ${WORKDIR}/${PN}/stx-files/public.py ${KEYSTONE_DATA_DIR}/public.py
196 install -m 644 ${WORKDIR}/${PN}/stx-files/openstack-keystone.service ${D}${systemd_system_unitdir}/openstack-keystone.service
197 install -m 755 ${WORKDIR}/${PN}/stx-files/keystone-all ${D}${bindir}/keystone-all
198
199}
200
201# By default tokens are expired after 1 day so by default we can set
202# this token flush cronjob to run every 2 days
203KEYSTONE_TOKEN_FLUSH_TIME ??= "0 0 */2 * *"
204
205pkg_postinst_${SRCNAME}-cronjobs () {
206 if [ -z "$D" ]; then
207 # By default keystone expired tokens are not automatic removed out of the
208 # database. So we create a cronjob for cleaning these expired tokens.
209 echo "${KEYSTONE_TOKEN_FLUSH_TIME} root /usr/bin/keystone-manage token_flush" >> /etc/crontab
210 fi
211}
212
213pkg_postinst_${SRCNAME} () {
214 # openstak-keystone will be run in httpd/apache2 instead of standalone
215 ln -sf ${systemd_system_unitdir}/apache2.service $D${sysconfdir}/systemd/system/openstack-keystone.service
216}
217
218PACKAGES += " ${SRCNAME}-tests ${SRCNAME} ${SRCNAME}-setup ${SRCNAME}-cronjobs"
219
220SYSTEMD_PACKAGES += "${SRCNAME}-setup"
221SYSTEMD_SERVICE_${SRCNAME}-setup = "keystone-init.service"
222SYSTEMD_SERVICE_${SRCNAME} = "openstack-keystone.service"
223
224SYSTEMD_AUTO_ENABLE_${SRCNAME}-setup = "disable"
225SYSTEMD_AUTO_ENABLE_${SRCNAME} = "disable"
226
227FILES_${SRCNAME}-setup = " \
228 ${systemd_system_unitdir}/keystone-init.service \
229 "
230
231ALLOW_EMPTY_${SRCNAME}-cronjobs = "1"
232
233FILES_${PN} = "${libdir}/* \
234 "
235
236FILES_${SRCNAME}-tests = "${sysconfdir}/${SRCNAME}/run_tests.sh"
237
238FILES_${SRCNAME} = "${bindir}/* \
239 ${sysconfdir}/${SRCNAME}/* \
240 ${localstatedir}/* \
241 ${datadir}/openstack-dashboard/openstack_dashboard/api/keystone-httpd.py \
242 ${sysconfdir}/apache2/conf.d/keystone.conf \
243 ${systemd_system_unitdir}/openstack-keystone.service \
244 "
245
246DEPENDS += " \
247 python-pip \
248 python-pbr-native \
249 "
250
251# Satisfy setup.py 'setup_requires'
252DEPENDS += " \
253 python-pbr-native \
254 "
255
256RDEPENDS_${PN} += " \
257 python-babel \
258 python-pbr \
259 python-webob \
260 python-pastedeploy \
261 python-paste \
262 python-routes \
263 python-cryptography \
264 python-six \
265 python-sqlalchemy \
266 python-sqlalchemy-migrate \
267 python-stevedore \
268 python-passlib \
269 python-keystoneclient \
270 python-keystonemiddleware \
271 python-bcrypt \
272 python-scrypt \
273 python-oslo.cache \
274 python-oslo.concurrency \
275 python-oslo.config \
276 python-oslo.context \
277 python-oslo.messaging \
278 python-oslo.db \
279 python-oslo.i18n \
280 python-oslo.log \
281 python-oslo.middleware \
282 python-oslo.policy \
283 python-oslo.serialization \
284 python-oslo.utils \
285 python-oauthlib \
286 python-pysaml2 \
287 python-dogpile.cache \
288 python-jsonschema \
289 python-pycadf \
290 python-msgpack \
291 python-osprofiler \
292 python-flask \
293 python-flask-restful \
294 python-pytz \
295 "
296
297RDEPENDS_${SRCNAME}-tests += " bash"
298
299PACKAGECONFIG ?= "${@bb.utils.contains('DISTRO_FEATURES', 'OpenLDAP', 'OpenLDAP', '', d)}"
300PACKAGECONFIG[OpenLDAP] = ",,,python-ldap python-keystone-hybrid-backend"
301
302# TODO:
303# if DISTRO_FEATURE contains "tempest" then add *-tests to the main RDEPENDS
304
305RDEPENDS_${SRCNAME} = " \
306 ${PN} \
307 postgresql \
308 postgresql-client \
309 python-psycopg2 \
310 apache2 \
311 "
312
313RDEPENDS_${SRCNAME}-setup = "postgresql sudo ${SRCNAME}"
314RDEPENDS_${SRCNAME}-cronjobs = "cronie ${SRCNAME}"
315
316MONITOR_SERVICE_PACKAGES = "${SRCNAME}"
317MONITOR_SERVICE_${SRCNAME} = "keystone"