-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdeploy_configurations.sh
executable file
·67 lines (48 loc) · 2.17 KB
/
deploy_configurations.sh
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
62
63
64
65
66
#!/bin/bash
# This script deploys all configuration channels to all subscribed systems
/bin/logger -t satellite ": job start [$0]"
source /var/satellite/maintenance/scrits/.satenv
SCRIPT_DIR="/var/satellite/maintenance/scripts"
API_SCRIPT="${SCRIPT_DIR}/spacewalk-api-custom --server=$SATELLITE_SERVER --user=$SATELLITE_LOGIN --password=$SATELLITE_PASSWORD"
TERM=xterm
export TERM LFSC API_SCRIPT
cd $SCRIPT_DIR
# Web API Call Prep
. ./automation-api-prep.sh
CAT=prevention
DESC="Deploying Configurations from the Satellite"
TIMESAVED=5
# Local log definition
SHORTLOG=`basename $0`.log
echo "Config channel deployment executed at `date`" >> $SHORTLOG
CONFIG_CHANNELS="
rhel-base-config
rhel7-base-config
rhel6-base-config
rhel5-base-config
sap-base-config
SAP-etc-services
oracle-db-base-config
"
for CC in `echo $CONFIG_CHANNELS`; do
# Deploy channel to all subscribed systems immediately
RESULT=`$API_SCRIPT configchannel.deployAllSystems "%session%" "$CC"`
if [[ -z `echo $RESULT | grep " = '1'"` ]]; then
echo "An error occured when attempting to deploy configuration channel [$CC]"
echo "Error Text: [$RESULT]"
echo ""
NOTES="An error occured: $RESULT"
fi
done
# Send Event
END=`date "+%Y-%m-%d %H:%M:%S"`
if [[ -z $NOTES ]]; then
SUCCESS=true
/usr/bin/curl -k -X POST --form "origin_hostname=$ORIGIN" --form "target_hostname=$TARGET" --form "processname=$PNAME" --form "triggeredby=$TB" --form "category=$CAT" --form "description=$DESC" --form "target_ip=$TARGETIP" --form "timesaved=$TIMESAVED" --form "datestarted=$START" --form "datefinished=$END" --form "success=$SUCCESS" --user ${API_USER}:${API_PASS} $API_URL 2>&1 | > /dev/null
#### END API CALL ####
else
SUCCESS=false
/usr/bin/curl -k -X POST --form "origin_hostname=$ORIGIN" --form "target_hostname=$TARGET" --form "processname=$PNAME" --form "triggeredby=$TB" --form "category=$CAT" --form "description=$DESC" --form "target_ip=$TARGETIP" --form "timesaved=$TIMESAVED" --form "datestarted=$START" --form "datefinished=$END" --form "success=$SUCCESS" --form "notes=$NOTES" --user ${API_USER}:${API_PASS} $API_URL 2>&1 | > /dev/null
fi
/bin/logger -t satellite ": job end [$0]"
exit