Repository navigation
Expand file tree
/
Copy path2-create-project.sh
More file actions
executable file
·61 lines (47 loc) · 2.56 KB
/
Copy path2-create-project.sh
File metadata and controls
executable file
·61 lines (47 loc) · 2.56 KB
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
#!/usr/bin/env bash
# SPDX-FileCopyrightText: 2025 @effndc
#
# SPDX-License-Identifier: Apache-2.0
# Please edit the ./user-variables.sh file to modify static or collected user variables.
set -euo pipefail
set -o nounset
CYAN='\033[0;36m'
RED='\033[0;31m'
GREEN='\033[0;32m'
NC='\033[0m' # No Color
# source KC utils
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
source "$DIR/user-variables.sh"
source "${DIR}/kc-utils.sh"
source "${DIR}/prompt-user.sh"
# Prompt if credentials missing
prompt_orch_credentials
# Auth for Keycloak/Orch Admin
#api_token ${KC_ADMINUSER} ${KC_ADMIN_PASSWORD} ${CLUSTER_FQDN}
KC_ADMIN_TOKEN=$(api_token "${KC_ADMINUSER}" "${KC_ADMIN_PASSWORD}" "${CLUSTER_FQDN}")
echo -e "${CYAN} Please get the name of of an Organization to create a Project in:${NC}"
# Usage getOrgs <cluster_fqdn> <jwt_token
getOrgs "${CLUSTER_FQDN}" "${KC_ADMIN_TOKEN}"
# Prompt for Organization name
prompt_org
# Prompt for Organization password for user accounts
echo -e "${RED} !!!! NOTE: In this next prompt you must provide the password for the previously created OrgAdmin account \n !!!! The password must match the one previously configured ${NC}"
prompt_org_admin_pass
prompt_org_user_pass
# Prompt for Oganization name
prompt_project
# 2 get Project Admin credentials for creating projects within Orch API
# Usage: api_token <user> <pass> <cluster_fqdn> <token_name> [realm] [client_id] [scope]
ORGADMIN_TOKEN=$(api_token "${org_name}-admin" "${ORG_ADMIN_PASS}" "${CLUSTER_FQDN}")
# 3 createProjectInOrg org_name project_name cluster_fqdn jwt_token
# Usage: createProjectInOrg <org_name> <project_name> <cluster_fqdn> <jwt_token>
createProjectInOrg "${org_name}" "${project_name}" "${CLUSTER_FQDN}" "${ORGADMIN_TOKEN}"
# 4 Create Project Admin
# Usage: createProjectAdmin <username> <org_name> <cluster_fqdn> <jwt_token>
createProjectAdmin "${org_name}-${project_name}-admin" "${org_name}" "${CLUSTER_FQDN}" "${KC_ADMIN_TOKEN}"
# 5 Create Project User
# Usage: createProjectUser <username> <org_name> <project_name> <cluster_fqdn> <jwt_token> <org_admin_token>
createProjectUser "${org_name}-${project_name}-user" "${org_name}" "${project_name}" "${CLUSTER_FQDN}" "${ORGADMIN_TOKEN}" "${KC_ADMIN_TOKEN}"
echo -e "${GREEN}Project ${NC} ${project_name} ${GREEN} and Organization users created successfully.${NC}"
echo -e "${GREEN}You may now login at ${NC}http://web-ui.${CLUSTER_FQDN} with the created user ${org_name}-${project_name}-user"
echo -e "${RED}Next step is create your Locations and Regions and then you are ready to onboard nodes and deploy apps${NC}"