Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
K
Kolla Ansible
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Very Demiurge Very Mindful
Kolla Ansible
Commits
8165fdf0
Commit
8165fdf0
authored
9 years ago
by
Jenkins
Committed by
Gerrit Code Review
9 years ago
Browse files
Options
Downloads
Plain Diff
Merge "Remove openstack client from keystone bootstrap"
parents
812b2786
215cfc03
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
docker/keystone/keystone_bootstrap.sh
+18
-58
18 additions, 58 deletions
docker/keystone/keystone_bootstrap.sh
with
18 additions
and
58 deletions
docker/keystone/keystone_bootstrap.sh
+
18
−
58
View file @
8165fdf0
...
...
@@ -14,12 +14,6 @@ INTERNAL_URL=$6
PUBLIC_URL
=
$7
REGION
=
$8
function
get_token
{
unset
OS_TOKEN OS_URL
OS_TOKEN
=
$(
openstack
--os-identity-api-version
3
--os-username
"
${
USERNAME
}
"
--os-password
"
${
PASSWORD
}
"
--os-project-name
"
${
PROJECT
}
"
--os-auth-url
"
${
ADMIN_URL
}
"
token issue 2>&1 |
awk
'/ id / {print $4}'
)
OS_URL
=
"
${
ADMIN_URL
}
"
}
function
fail_json
{
echo
'{"failed": true, "msg": "'
$1
'", "changed": true}'
exit
1
...
...
@@ -29,60 +23,26 @@ function exit_json {
echo
'{"failed": false, "changed": '
"
${
changed
}
"
'}'
}
function
create_service
{
if
[[
!
$(
openstack
--os-identity-api-version
3
--os-token
"
${
OS_TOKEN
}
"
--os-url
"
${
OS_URL
}
"
service list 2>&1 |
awk
'/identity/'
)
]]
;
then
openstack
--os-identity-api-version
3
--os-token
"
${
OS_TOKEN
}
"
--os-url
"
${
OS_URL
}
"
service create identity
--name
keystone 2>&1
>
/dev/null
changed
=
"true"
fi
}
function
create_endpoints
{
endpoints
=
$(
openstack
--os-identity-api-version
3
--os-token
"
${
OS_TOKEN
}
"
--os-url
"
${
OS_URL
}
"
endpoint list
)
if
[[
$(
echo
"
${
endpoints
}
"
|
awk
'$6 == "keystone" && $4 == "'
"
${
REGION
}
"
'" && $12 == "admin" {print $14;exit}'
)
!=
"
${
ADMIN_URL
}
"
]]
;
then
openstack
--os-identity-api-version
3
--os-token
"
${
OS_TOKEN
}
"
--os-url
"
${
OS_URL
}
"
endpoint create
--region
"
${
REGION
}
"
keystone admin
"
${
ADMIN_URL
}
"
2>&1
>
/dev/null
changed
=
"true"
fi
if
[[
$(
echo
"
${
endpoints
}
"
|
awk
'$6 == "keystone" && $4 == "'
"
${
REGION
}
"
'" && $12 == "internal" {print $14;exit}'
)
!=
"
${
INTERNAL_URL
}
"
]]
;
then
openstack
--os-identity-api-version
3
--os-token
"
${
OS_TOKEN
}
"
--os-url
"
${
OS_URL
}
"
endpoint create
--region
"
${
REGION
}
"
keystone internal
"
${
INTERNAL_URL
}
"
2>&1
>
/dev/null
changed
=
"true"
fi
if
[[
$(
echo
"
${
endpoints
}
"
|
awk
'$6 == "keystone" && $4 == "'
"
${
REGION
}
"
'" && $12 == "public" {print $14;exit}'
)
!=
"
${
PUBLIC_URL
}
"
]]
;
then
openstack
--os-identity-api-version
3
--os-token
"
${
OS_TOKEN
}
"
--os-url
"
${
OS_URL
}
"
endpoint create
--region
"
${
REGION
}
"
keystone public
"
${
PUBLIC_URL
}
"
2>&1
>
/dev/null
changed
=
"true"
fi
}
changed
=
"false"
get_token
if
[[
!
$(
openstack
--os-identity-api-version
3
--os-token
"
${
OS_TOKEN
}
"
--os-url
"
${
OS_URL
}
"
user list 2>&1 |
awk
'/'
"
${
USERNAME
}
"
'/'
)
]]
;
then
keystone_bootstrap
=
$(
keystone-manage bootstrap
--bootstrap-username
"
${
USERNAME
}
"
--bootstrap-password
"
${
PASSWORD
}
"
--bootstrap-project-name
"
${
PROJECT
}
"
--bootstrap-role-name
"
${
ROLE
}
"
2>&1
)
if
[[
$?
!=
0
]]
;
then
fail_json
"
${
keystone_bootstrap
}
"
fi
changed
=
$(
echo
"
${
keystone_bootstrap
}
"
|
awk
'
/Domain default already exists, skipping creation./ ||
/Project '
"
${
PROJECT
}
"
' already exists, skipping creation./ ||
/User '
"
${
USERNAME
}
"
' already exists, skipping creation./ ||
/Role '
"
${
ROLE
}
"
' exists, skipping creation./ ||
/User '
"
${
USERNAME
}
"
' already has '
"
${
ROLE
}
"
' on '
"
${
PROJECT
}
"
'./ {count++}
END {
if (count == 5) changed="false"; else changed="true"
print changed
}'
)
keystone_bootstrap
=
$(
keystone-manage bootstrap
--bootstrap-username
"
${
USERNAME
}
"
--bootstrap-password
"
${
PASSWORD
}
"
--bootstrap-project-name
"
${
PROJECT
}
"
--bootstrap-role-name
"
${
ROLE
}
"
--bootstrap-admin-url
"
${
ADMIN_URL
}
"
--bootstrap-internal-url
"
${
INTERNAL_URL
}
"
--bootstrap-public-url
"
${
PUBLIC_URL
}
"
--bootstrap-service-name
"keystone"
--bootstrap-region-id
"
${
REGION
}
"
2>&1
)
if
[[
$?
!=
0
]]
;
then
fail_json
"
${
keystone_bootstrap
}
"
fi
count
=
0
while
[[
!
"
${
OS_TOKEN
}
"
&&
"
${
count
}
"
-lt
5
]]
;
do
get_token
((
count++
))
sleep
1
done
if
[[
!
"
${
OS_TOKEN
}
"
]]
;
then
fail_json
"Unable to retrieve token after 5 attempts"
fi
changed
=
$(
echo
"
${
keystone_bootstrap
}
"
|
awk
'
/Domain default already exists, skipping creation./ ||
/Project '
"
${
PROJECT
}
"
' already exists, skipping creation./ ||
/User '
"
${
USERNAME
}
"
' already exists, skipping creation./ ||
/Role '
"
${
ROLE
}
"
' exists, skipping creation./ ||
/User '
"
${
USERNAME
}
"
' already has '
"
${
ROLE
}
"
' on '
"
${
PROJECT
}
"
'./ ||
/Region '
"
${
REGION
}
"
' exists, skipping creation./ ||
/Skipping admin endpoint as already created/ ||
/Skipping internal endpoint as already created/ ||
/Skipping public endpoint as already created/ {count++}
END {
if (count == 9) changed="false"; else changed="true"
print changed
}'
)
create_service
create_endpoints
exit_json
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment