This appendix describes how to write a scripts to invoke all of the scripts from a single host.
It is possible to write a script to invoke all of the scripts from a single host, in effect creating a one command deployment.
Below are sample scripts which can be modified to achieve this.
Disclaimer:
These scripts are example implementations and are provided as is as a proof of concept to demonstrate a method to automate the deployment process. The scripts must be customized and tested for the specific need of your environment.
This appendix includes the following topics:
This script sets the environment.
#!/bin/sh
#
# setenv.sh
#
# Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
#
# NAME
# setenv.sh - captures details of environment to be deployed
#
# DESCRIPTION
# <short description of component this file declares/defines>
#
# NOTES
# <other useful comments, qualifications, etc.>
#
# MODIFIED (MM/DD/YY)
#
CURRENT_HOST=`hostname`
export USERNAME=<unix user eg oracle>
export IDMTOP=SW_ROOT
export SHARED_CONFIG_DIR=$IDMTOP/config
export LOCAL_CONFIG_DIR=<LOCAL_ROOT>
export REPOSITORY=<REPOS_HOME>
export INSTALLERS=$REPOSITORY/installers
export RESPONSE_FILE=<FULLY QUALIFIED PATH TO DEPLOYMENT RESPONSE FILE>
export PROVISIONING=<IDMLCM_HOME>/provisioning
export SCRIPTS_DIR=<DIRECTORY CONTAINING THESE SCRIPTS>
export JAVA_HOME=$REPOSITORY/jdk6
export ANT_HOME=$REPOSITORY/provisioning/ant
export PRIMORDIAL_TO_DMZ_SHARE=$PROVISIONING/dmzShare
export RCU_HOME=$INSTALLERS/rcu
export RCU_LOG_LOCATION=$SCRIPTS_DIR/rcu/logs-$$
export RCU_LOG_NAME=rcu.log
export RCU_TIMESTAMP_LOG_DIR=false
export DB_SCHEMA_PREFIX=DEV
PHASES_TO_RUN='preverify install preconfigure configure configure-secondary postconfigure startup validate'
export ALL_HOSTS='<LDAPHOST1> <LDAPHOST2> <OAMHOST1> <OAMHOST2> <OIMHOST1> <OIMHOST2> <WEBHOST1> <WEBHOST2>'
export DB_CONNECT_STRING=<DB-SCAN>:<DB_LSNR_PORT>:<IDSTORE_SERVICE_NAME>
export DB_PASSWORD_SYS=<DB SYS PWD>
export DB_PASSWORD_SCHEMA=<RCU_SCHEMA_PASSWORD>
mkdir -p $PRIMORDIAL_TO_DMZ_SHARE
function timer()
{
if [[ $# -eq 0 ]]; then
echo $(date '+%s')
else
local stime=$1
etime=$(date '+%s')
if [[ -z "$stime" ]]; then stime=$etime; fi
dt=$((etime - stime))
ds=$((dt % 60))
dm=$(((dt / 60) % 60))
dh=$((dt / 3600))
printf '%d:%02d:%02d' $dh $dm $ds
fi
}
execCmd()
{
HOST=$1
shift
CMD_LINE=$*
CMD="ssh $USERNAME@$HOST $CMD_LINE"
echo "[idmprov] " `date` $CMD
tmr=$(timer)
$CMD
printf '[idmprov] Elapsed time: %s\n' $(timer $tmr)
}
#!/bin/sh # # setlocalenv.sh # # Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. # # NAME # setenv.sh - captures details of environment to be deployed # # DESCRIPTION # <short description of component this file declares/defines> # # NOTES # <other useful comments, qualifications, etc.> # # MODIFIED (MM/DD/YY) # CURRENT_HOST=`hostname` export USERNAME=<software owner> export IDMTOP=<SW_ROOT> export SHARED_CONFIG_DIR=$IDMTOP/config export LOCAL_CONFIG_DIR=<LOCAL_ROOT> export REPOSITORY=<REPOS_HOME> export INSTALLERS=$REPOSITORY/installers export RESPONSE_FILE=<FULLY QUALIFIED PATH TO DEPLOYMENT RESPONSE FILE> export PROVISIONING=<IDMLCM_HOME>/provisioning export SCRIPTS_DIR=<DIRECTORY CONTAINING THESE SCRIPTS> export JAVA_HOME=$REPOSITORY/jdk6 export ANT_HOME=$REPOSITORY/provisioning/ant export PRIMORDIAL_TO_DMZ_SHARE=$PROVISIONING/dmzShare
This is the Deployment script.
#!/bin/sh # # deploy.sh # # Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. # # NAME # provision.sh - this script starts executing Deployment phases in all hosts # # DESCRIPTION # <short description of component this file declares/defines> # # NOTES # - copy all scripts named prov_*.sh to a directory in primordial host # - make sure this directory is accessible using the same path from all hosts being provisioned # - update prov_env.sh with environment specific details (directories, hostnames, db, etc) # - run this script from the primordial host # - script will create one log file for each phase in each host - named prov_run-<phase>-<host>.log # - script will stop when Deployment completes or on detecting 1st failure (absence of "BUILD SUCCESSFUL" in the log file) # # MODIFIED (MM/DD/YY) # . <DIRECTORY CONTAINING THESE SCRIPTS>/setenv.sh if [ ! -e $SCRIPTS_DIR/logs ]then mkdir -p $SCRIPTS_DIR/logs fi rm -r $SCRIPTS_DIR/logs/* LCM_ROOT/provisioning* <LCM_ROOT>/internal LCM_ROOT/lcmconfig LCM_ROOT/keystores 2> /dev/null starttmr=$(timer) for PHASE in $PHASES_TO_RUN do phasetmr=$(timer) for HOST in $ALL_HOSTS do echo "[idmprov] Running $PHASE on $HOST" logFile=$SCRIPTS_DIR/logs/$PHASE-$HOST.log execCmd $HOST ". $SCRIPTS_DIR/setlocalenv.sh; cd $PROVISIONING/bin; ./runIAMDeployment.sh -responseFile $RESPONSE_FILE -target $PHASE" > $logFile fgrep -s "BUILD SUCCESSFUL" $logFile if [ "$?" = "1" ] then echo "ERROR: $PHASE failed in $HOST" exit 1 fi done echo -e "[idmprov] Total $PHASE\c" printf ' time: %s\n' $(timer $phasetmr) done printf '[idmprov] Total Elapsed time: %s\n' $(timer $starttmr)
Use the scripts as follows:
Copy the scripts to a location that is available on each host in the topology.
Edit the scripts and replace entries like <SW_ROOT>
with entries applicable to your environment. Use Section 7.1, "Assembling Information for Identity and Access Management Deployment," to assist with this.
Set up ssh
equivalence from the primordial host to each of the other hosts in the topology. See your operating system documentation for details.
Validate that ssh
equivalence is working by issuing the following command from the primordial host to each host in the topology. This command should show the date on each remote machine without any prompts:
ssh hostname date
Copy the deployment response file generated in Chapter 8, "Creating a Deployment Profile," to the same directory where these scripts are located.
Run the deploy.sh
script.
After deployment is complete, remove the ssh
equivalence.