Skip to content

Commit dbb3baf

Browse files
authored
IDM EDG Automation 3.0 (#109)
1 parent b815da2 commit dbb3baf

File tree

86 files changed

+6881
-1291
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

86 files changed

+6881
-1291
lines changed

FMWKubernetesMAA/OracleEnterpriseDeploymentAutomation/OracleIdentityManagement/README.md

Lines changed: 748 additions & 562 deletions
Large diffs are not rendered by default.

FMWKubernetesMAA/OracleEnterpriseDeploymentAutomation/OracleIdentityManagement/common/functions.sh

Lines changed: 77 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ export SAMPLES_DIR=`echo $SAMPLES_REP | awk -F "/" '{print $NF}' | sed 's/.git/
2020

2121
SSH="ssh -q"
2222

23+
2324
# Create local Directories
2425
#
2526
create_local_workdir()
@@ -64,10 +65,12 @@ create_registry_secret()
6465
pass=$3
6566
namespace=$4
6667

68+
credname=${5:-"regcred"}
69+
6770
ST=`date +%s`
6871
print_msg "Creating Container Registry Secret in namespace $namespace"
6972

70-
kubectl create secret -n $namespace docker-registry regcred --docker-server=$registry --docker-username=$username --docker-password=$pass > $LOGDIR/create_reg_secret.log 2>&1
73+
kubectl create secret -n $namespace docker-registry $credname --docker-server=$registry --docker-username=$username --docker-password=$pass > $LOGDIR/create_reg_secret.log 2>&1
7174
grep -q created $LOGDIR/create_reg_secret.log
7275
if [ $? = 0 ]
7376
then
@@ -82,8 +85,40 @@ create_registry_secret()
8285
exit 1
8386
fi
8487
fi
88+
ET=`date +%s`
89+
print_time STEP "Creating Container Registry Secret in namespace $namespace" $ST $ET >> $LOGDIR/timings.log
8590
}
8691

92+
#
93+
# Create github Registry Secret
94+
#
95+
create_git_secret()
96+
{
97+
username=$1
98+
token=$2
99+
namespace=$3
100+
101+
ST=`date +%s`
102+
print_msg "Creating GitHub Secret in namespace $namespace"
103+
104+
kubectl create secret -n $namespace docker-registry github --docker-server=ghcr.io --docker-username=$username --docker-password="$token" > $LOGDIR/create_git_secret.log 2>&1
105+
grep -q created $LOGDIR/create_git_secret.log
106+
if [ $? = 0 ]
107+
then
108+
echo "Success"
109+
else
110+
grep -q exists $LOGDIR/create_git_secret.log
111+
if [ $? = 0 ]
112+
then
113+
echo "Already Exists"
114+
else
115+
echo "Failed - See $LOGDIR/create_git_secret.log."
116+
exit 1
117+
fi
118+
fi
119+
ET=`date +%s`
120+
print_time STEP "Creating GitHub Secret" $ST $ET >> $LOGDIR/timings.log
121+
}
87122
#
88123
check_oper_exists()
89124
{
@@ -117,18 +152,6 @@ install_operator()
117152
print_time STEP "Install Operator" $ST $ET >> $LOGDIR/timings.log
118153

119154
}
120-
upgrade_operator()
121-
{
122-
nslist=$1
123-
ST=`date +%s`
124-
125-
print_msg "Adding Namespaces:$nslist to Operator"
126-
cd $WORKDIR/weblogic-kubernetes-operator
127-
helm upgrade --reuse-values --namespace $OPERNS --set "domainNamespaces={$nslist}" --wait weblogic-kubernetes-operator kubernetes/charts/weblogic-operator > $LOGDIR/upgrade_operator.log 2>&1
128-
print_status $? $LOGDIR/upgrade_operator.log
129-
ET=`date +%s`
130-
print_time STEP "Add Namespaces:$nslist to Operator" $ST $ET >> $LOGDIR/timings.log
131-
}
132155

133156
# Kubernetes Functions
134157
#
@@ -179,8 +202,10 @@ get_k8_port()
179202
{
180203
SVC=$1
181204
NS=$2
205+
TYP=${3:-"http"}
206+
182207

183-
PORTS=`kubectl get service -n $NS | grep NodePort | grep $SVC | awk '{ print $5 }'`
208+
PORTS=`kubectl get service -n $NS | grep NodePort | grep "$SVC " | awk '{ print $5 }'`
184209

185210
PORT1=(`echo $PORTS | cut -f1 -d, | sed 's/\/TCP//;s/:/ /'`)
186211
PORT2=(`echo $PORTS | cut -f2 -d, | sed 's/\/TCP//;s/:/ /'`)
@@ -191,7 +216,7 @@ get_k8_port()
191216
then
192217
echo ${PORT1[1]}
193218
else
194-
if [ ${PORT1[0]} = 80 ]
219+
if [ ${PORT1[0]} = 80 ] && [ "$TYP" = "http" ]
195220
then
196221
echo ${PORT1[1]}
197222
else
@@ -704,6 +729,11 @@ update_variable()
704729
VAR=$1
705730
VAL=$2
706731
FILE=$3
732+
if [ "$VAL" = "" ]
733+
then
734+
echo "Unable to update variable: $VAR with $VAL"
735+
exit 1
736+
fi
707737
NEWVAL=$(echo $VAL | sed 's/\//\\\//g')
708738
sed -i "s/$VAR/$NEWVAL/g" $FILE
709739
if [ "$?" = "1" ]
@@ -749,48 +779,48 @@ create_schemas ()
749779
printf "$RCUPWD\n" >> /tmp/pwd.txt
750780
print_msg "Creating $SCHEMA_TYPE Schemas"
751781

752-
printf "#!/bin/bash\n" > $WORKDIR/create_schema.sh
753-
printf "/u01/oracle/oracle_common/bin/rcu -silent -createRepository -databaseType ORACLE " >> $WORKDIR/create_schema.sh
754-
printf " -connectString $DB_HOST:$DB_PORT/$DB_SERVICE " >> $WORKDIR/create_schema.sh
755-
printf " -dbUser sys -dbRole sysdba -useSamePasswordForAllSchemaUsers true -selectDependentsForComponents true " >> $WORKDIR/create_schema.sh
756-
printf " -schemaPrefix $RCU_PREFIX" >> $WORKDIR/create_schema.sh
782+
printf "#!/bin/bash\n" > /tmp/create_schema.sh
783+
printf "/u01/oracle/oracle_common/bin/rcu -silent -createRepository -databaseType ORACLE " >> /tmp/create_schema.sh
784+
printf " -connectString $DB_HOST:$DB_PORT/$DB_SERVICE " >> /tmp/create_schema.sh
785+
printf " -dbUser sys -dbRole sysdba -useSamePasswordForAllSchemaUsers true -selectDependentsForComponents true " >> /tmp/create_schema.sh
786+
printf " -schemaPrefix $RCU_PREFIX" >> /tmp/create_schema.sh
757787

758788
if [ "$SCHEMA_TYPE" = "OIG" ]
759789
then
760-
printf "$OIG_SCHEMAS" >> $WORKDIR/create_schema.sh
790+
printf "$OIG_SCHEMAS" >> /tmp/create_schema.sh
761791
elif [ "$SCHEMA_TYPE" = "OAM" ]
762792
then
763-
printf "$OAM_SCHEMAS" >> $WORKDIR/create_schema.sh
793+
printf "$OAM_SCHEMAS" >> /tmp/create_schema.sh
764794
else
765795
printf "\nInvalid Schema Type: $SCHEMA_TYPE \n"
766796
exit 1
767797
fi
768798

769-
printf " -f < /tmp/pwd.txt \n" >> $WORKDIR/create_schema.sh
770-
printf " exit \n" >> $WORKDIR/create_schema.sh
799+
printf " -f < /tmp/pwd.txt \n" >> /tmp/create_schema.sh
800+
printf " exit \n" >> /tmp/create_schema.sh
771801

772802
kubectl cp /tmp/pwd.txt $NAMESPACE/helper:/tmp
773-
kubectl cp $WORKDIR/create_schema.sh $NAMESPACE/helper:/tmp
803+
kubectl cp /tmp/create_schema.sh $NAMESPACE/helper:/tmp
774804
kubectl exec -n $NAMESPACE -ti helper -- /bin/bash < /tmp/create_schema.sh > $LOGDIR/create_schemas.log 2>&1
775805
print_status $? $LOGDIR/create_schemas.log
776806
if [ "$SCHEMA_TYPE" = "OIG" ]
777807
then
778808
printf "\t\t\tPatching OIM Schema - "
779-
printf "/u01/oracle/oracle_common/modules/thirdparty/org.apache.ant/1.10.5.0.0/apache-ant-1.10.5/bin/ant " >> $WORKDIR/patch_schema.sh
780-
printf " -f /u01/oracle/idm/server/setup/deploy-files/automation.xml " >> $WORKDIR/patch_schema.sh
781-
printf " run-patched-sql-files " >> $WORKDIR/patch_schema.sh
782-
printf " -logger org.apache.tools.ant.NoBannerLogger " >> $WORKDIR/patch_schema.sh
783-
printf " -logfile /tmp/patch_oim_wls.log " >> $WORKDIR/patch_schema.sh
784-
printf " -DoperationsDB.host=$DB_HOST" >> $WORKDIR/patch_schema.sh
785-
printf " -DoperationsDB.port=$DB_PORT " >> $WORKDIR/patch_schema.sh
786-
printf " -DoperationsDB.serviceName=$DB_SERVICE " >> $WORKDIR/patch_schema.sh
787-
printf " -DoperationsDB.user=${RCU_PREFIX}_OIM " >> $WORKDIR/patch_schema.sh
788-
printf " -DOIM.DBPassword=$RCUPWD " >> $WORKDIR/patch_schema.sh
789-
printf " -Dojdbc=/u01/oracle/oracle_common/modules/oracle.jdbc/ojdbc8.jar \n" >> $WORKDIR/patch_schema.sh
790-
printf "exit \n" >> $WORKDIR/patch_schema.sh
791-
792-
793-
kubectl cp $WORKDIR/patch_schema.sh $NAMESPACE/helper:/tmp
809+
printf "/u01/oracle/oracle_common/modules/thirdparty/org.apache.ant/1.10.5.0.0/apache-ant-1.10.5/bin/ant " >> /tmp/patch_schema.sh
810+
printf " -f /u01/oracle/idm/server/setup/deploy-files/automation.xml " >> /tmp/patch_schema.sh
811+
printf " run-patched-sql-files " >> /tmp/patch_schema.sh
812+
printf " -logger org.apache.tools.ant.NoBannerLogger " >> /tmp/patch_schema.sh
813+
printf " -logfile /tmp/patch_oim_wls.log " >> /tmp/patch_schema.sh
814+
printf " -DoperationsDB.host=$DB_HOST" >> /tmp/patch_schema.sh
815+
printf " -DoperationsDB.port=$DB_PORT " >> /tmp/patch_schema.sh
816+
printf " -DoperationsDB.serviceName=$DB_SERVICE " >> /tmp/patch_schema.sh
817+
printf " -DoperationsDB.user=${RCU_PREFIX}_OIM " >> /tmp/patch_schema.sh
818+
printf " -DOIM.DBPassword=$RCUPWD " >> /tmp/patch_schema.sh
819+
printf " -Dojdbc=/u01/oracle/oracle_common/modules/oracle.jdbc/ojdbc8.jar \n" >> /tmp/patch_schema.sh
820+
printf "exit \n" >> /tmp/patch_schema.sh
821+
822+
823+
kubectl cp /tmp/create_schema.sh $NAMESPACE/helper:/tmp
794824
kubectl exec -n $NAMESPACE -ti helper -- /bin/bash < /tmp/patch_schema.sh > $LOGDIR/patch_schema.log 2>&1
795825
kubectl cp $NAMESPACE/helper:/tmp/patch_oim_wls.log $LOGDIR/patch_oim_wls.log > /dev/null
796826
grep -q "BUILD SUCCESSFUL" $LOGDIR/patch_oim_wls.log
@@ -860,19 +890,20 @@ check_running()
860890
{
861891
NAMESPACE=$1
862892
SERVER_NAME=$2
893+
DELAY=$3
863894

864895
printf "\t\t\tChecking $SERVER_NAME "
865896
if [ "$SERVER_NAME" = "adminserver" ]
866897
then
867898
sleep 120
868899
else
869-
sleep 10
900+
sleep ${DELAY:=10}
870901
fi
871902
X=0
872903
while [ "$X" = "0" ]
873904
do
874905

875-
POD=`kubectl --namespace $NAMESPACE get pod -o wide | grep $SERVER_NAME `
906+
POD=`kubectl --namespace $NAMESPACE get pod -o wide | grep $SERVER_NAME | head -1 `
876907
if [ "$POD" = "" ]
877908
then
878909
JOB_STATUS=`kubectl --namespace $NAMESPACE get pod -o wide | grep infra-domain-job | awk '{ print $3 }'`
@@ -944,7 +975,7 @@ check_stopped()
944975
if [ "$RUNNING" = "1/1" ]
945976
then
946977
echo -e ".\c"
947-
sleep 60
978+
sleep 10
948979
else
949980
echo "Stopped"
950981
X=1
@@ -1081,7 +1112,7 @@ copy_ohs_config()
10811112
print_msg "Copying OHS configuration Files to OHS Servers"
10821113
printf "\n\t\t\tOHS Server $OHS_HOST1 - "
10831114

1084-
scp $LOCAL_WORKDIR/OHS/$OHS_HOST1/* $OHS_HOST1:$OHS_DOMAIN/config/fmwconfig/components/OHS/$OHS1_NAME/moduleconf/ > $LOGDIR/copy_ohs.log 2>&1
1115+
scp $LOCAL_WORKDIR/OHS/$OHS_HOST1/*vh.conf $OHS_HOST1:$OHS_DOMAIN/config/fmwconfig/components/OHS/$OHS1_NAME/moduleconf/ > $LOGDIR/copy_ohs.log 2>&1
10851116
print_status $? $LOGDIR/copy_ohs.log
10861117

10871118
if [ "$COPY_WG_FILES" = "true" ]
@@ -1100,7 +1131,7 @@ copy_ohs_config()
11001131
then
11011132
printf "\n\t\t\tOHS Server $OHS_HOST2 - "
11021133

1103-
scp $LOCAL_WORKDIR/OHS/$OHS_HOST2/* $OHS_HOST2:$OHS_DOMAIN/config/fmwconfig/components/OHS/$OHS2_NAME/moduleconf/ >> $LOGDIR/copy_ohs.log 2>&1
1134+
scp $LOCAL_WORKDIR/OHS/$OHS_HOST2/*vh.conf $OHS_HOST2:$OHS_DOMAIN/config/fmwconfig/components/OHS/$OHS2_NAME/moduleconf/ >> $LOGDIR/copy_ohs.log 2>&1
11041135
print_status $? $LOGDIR/copy_ohs.log
11051136

11061137
if [ "$COPY_WG_FILES" = "true" ]
@@ -1170,3 +1201,4 @@ function check_lbr()
11701201
fi
11711202
}
11721203

1204+
Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
#!/bin/bash
2+
# Copyright (c) 2022, Oracle and/or its affiliates.
3+
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
4+
#
5+
# This is an example of functions used to create an Ingress Controller
6+
#
7+
#
8+
# Dependencies:
9+
#
10+
#
11+
# Usage: invoked as needed not directly
12+
#
13+
# Common Environment Variables
14+
#
15+
16+
17+
# Create Ingress Certificate
18+
#
19+
create_ingress_cert()
20+
{
21+
ST=`date +%s`
22+
print_msg "Creating Certificate for Domain: *.$INGRESS_DOMAIN"
23+
cp $TEMPLATES_DIR/ssl_cert_config.txt $WORKDIR
24+
update_variable "<INGRESS_DOMAIN>" $INGRESS_DOMAIN $WORKDIR/ssl_cert_config.txt
25+
openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout $WORKDIR/ingress.key -out $WORKDIR/ingress.crt -config $WORKDIR/ssl_cert_config.txt -extensions v3_req > $LOGDIR/create_cert.log 2>&1
26+
print_status $? $LOGDIR/create_cert.log
27+
28+
printf "\t\t\tCreate Kubernetes Secret from Certificate - "
29+
30+
kubectl -n $INGRESSNS create secret tls common-tls-cert --key $WORKDIR/ingress.key --cert $WORKDIR/ingress.crt > $LOGDIR/create_cert_secret.log 2>&1
31+
grep -q created $LOGDIR/create_cert_secret.log
32+
if [ $? = 0 ]
33+
then
34+
echo "Success"
35+
else
36+
grep -q exists $LOGDIR/create_cert_secret.log
37+
if [ $? = 0 ]
38+
then
39+
echo "Already Exists"
40+
else
41+
echo kubectl -n $INGRESSNS create secret tls common-tls-cert --key $WORKDIR/ingress.key --cert $WORKDIR/ingress.crt > $LOGDIR/create_cert_secret.log 2>&1
42+
echo "Failed - See $LOGDIR/create_cert_secret.log."
43+
exit 1
44+
fi
45+
fi
46+
ET=`date +%s`
47+
print_time STEP "Creating Ingress" $ST $ET >> $LOGDIR/timings.log
48+
}
49+
50+
# Add ingress to Helm repository
51+
#
52+
create_ingress_repo()
53+
{
54+
ST=`date +%s`
55+
print_msg "Adding Ingress Repository "
56+
57+
helm repo add stable https://kubernetes.github.io/ingress-nginx > $LOGDIR/ingress.log 2>&1
58+
print_status $? $LOGDIR/ingress.log 2>&1
59+
60+
printf "\t\t\tUpdate Ingress Repository - "
61+
helm repo update >> $LOGDIR/ingress.log 2>&1
62+
print_status $? $LOGDIR/ingress.log 2>&1
63+
64+
65+
ET=`date +%s`
66+
print_time STEP "Add Ingress Repository" $ST $ET >> $LOGDIR/timings.log
67+
}
68+
69+
70+
#
71+
# Create Ingress Controller using override file
72+
#
73+
create_ingress_controller()
74+
{
75+
ST=`date +%s`
76+
print_msg "Create Ingress Controller "
77+
78+
if [ "$INGRESS_ENABLE_TCP" = "true" ]
79+
then
80+
cp $TEMPLATES_DIR/ldap_override.yaml $WORKDIR/ingress_override.yaml
81+
update_variable "<OUDNS>" $OUDNS $WORKDIR/ingress_override.yaml
82+
update_variable "<OUD_POD_PREFIX>" $OUD_POD_PREFIX $WORKDIR/ingress_override.yaml
83+
update_variable "<OUD_POD_PREFIX>" $OUD_POD_PREFIX $WORKDIR/ingress_override.yaml
84+
update_variable "<OUD_LDAP_K8>" $OUD_LDAP_K8 $WORKDIR/ingress_override.yaml
85+
update_variable "<OUD_LDAPS_K8>" $OUD_LDAPS_K8 $WORKDIR/ingress_override.yaml
86+
else
87+
cp $TEMPLATES_DIR/ingress_override.yaml $WORKDIR/ingress_override.yaml
88+
fi
89+
90+
filename=$WORKDIR/ingress_override.yaml
91+
update_variable "<INGRESS_NAME>" $INGRESS_NAME $filename
92+
update_variable "<INGRESS_REPLICAS>" $INGRESS_REPLICAS $filename
93+
update_variable "<INGRESS_HTTP_K8>" $INGRESS_HTTP_K8 $filename
94+
update_variable "<INGRESS_HTTPS_K8>" $INGRESS_HTTPS_K8 $filename
95+
96+
97+
helm install nginx-ingress -n $INGRESSNS --values $filename\
98+
stable/ingress-nginx > $LOGDIR/create_controller.log 2>&1
99+
grep -q DEPLOYED $LOGDIR/create_controller.log
100+
print_status $? $LOGDIR/create_controller.log
101+
102+
ET=`date +%s`
103+
print_time STEP "Create Ingress Controller" $ST $ET >> $LOGDIR/timings.log
104+
}
105+

0 commit comments

Comments
 (0)