-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprepOpenShift.sh
executable file
·146 lines (116 loc) · 2.88 KB
/
prepOpenShift.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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
#!/bin/sh
#
DATE=$(date '+%H%M%S%m%d%y')
TMPFILE=$(mktemp)
TMPFILEB=$(mktemp)
TMPFILEC=$(mktemp)
STEP=0
BASEDIR=$(pwd)
while getopts s optargs
do
case "${optargs}" in
s) STEP=1;;
esac
done
if [ -d ./oslab ]
then
echo "Moving old oslab directory ..."
mv oslab oslab.$DATE
fi
echo -n "Creating new install directory... "
mkdir ./oslab
echo "Done."
if [ "$STEP" -eq 1 ]
then
echo -n "Continue? [y/n]: "
read ANSWER
[ "$ANSWER" = "n" ] && exit 0
fi
echo -n "Copying install config to install directory ... "
cp ${HOME}/OpenShift_install-config.yaml ./oslab/install-config.yaml
echo "Done."
if [ "$STEP" -eq 1 ]
then
echo -n "Continue? [y/n]: "
read ANSWER
[ "$ANSWER" = "n" ] && exit 0
fi
echo "Creating manifests ..."
./openshift-install create manifests --dir=${BASEDIR}/oslab
echo "Done."
if [ "$STEP" -eq 1 ]
then
echo -n "Continue? [y/n]: "
read ANSWER
[ "$ANSWER" = "n" ] && exit 0
fi
echo -n "Editing cluster-scheduler-02-config.yml ..."
sed -e 's/mastersSchedulable: true/mastersSchedulable: False/' ./oslab/manifests/cluster-scheduler-02-config.yml > $TMPFILE
mv $TMPFILE ./oslab/manifests/cluster-scheduler-02-config.yml
echo "Done."
if [ "$STEP" -eq 1 ]
then
echo -n "Continue? [y/n]: "
read ANSWER
[ "$ANSWER" = "n" ] && exit 0
fi
echo "Creating ignition configs..."
./openshift-install create ignition-configs --dir=${BASEDIR}/oslab
echo "Done."
if [ "$STEP" -eq 1 ]
then
echo -n "Continue? [y/n]: "
read ANSWER
[ "$ANSWER" = "n" ] && exit 0
fi
echo -n "Copy append-bootstrap ... "
cp ${HOME}/append-bootstrap.ign ./oslab
echo "Done."
if [ "$STEP" -eq 1 ]
then
echo -n "Continue? [y/n]: "
read ANSWER
[ "$ANSWER" = "n" ] && exit 0
fi
echo -n "Copy bootstrap ... "
cp ${BASEDIR}/oslab/bootstrap.ign /install/bootstrap.ign
echo "Done."
if [ "$STEP" -eq 1 ]
then
echo -n "Continue? [y/n]: "
read ANSWER
[ "$ANSWER" = "n" ] && exit 0
fi
echo -n "Convert to base64 ..."
base64 -w0 ./oslab/master.ign > ./oslab/master.64
base64 -w0 ./oslab/worker.ign > ./oslab/worker.64
base64 -w0 ./oslab/append-bootstrap.ign > ./oslab/append-bootstrap.64
echo "Done."
if [ "$STEP" -eq 1 ]
then
echo -n "Continue? [y/n]: "
read ANSWER
[ "$ANSWER" = "n" ] && exit 0
fi
echo -n "Editing update template Ansible yaml ... "
sed -e "s/GUESTINFOBOOTSTRAP/$(cat oslab/append-bootstrap.64)/" ${HOME}/playbooks/edit_oslab_template.yaml > $TMPFILE
sed -e "s/GUESTINFOMASTER/$(cat oslab/master.64)/" $TMPFILE > $TMPFILEB
sed -e "s/GUESTINFOWORKER/$(cat oslab/worker.64)/" $TMPFILEB > $TMPFILEC
rm $TMPFILE
rm $TMPFILEB
mv $TMPFILEC ${HOME}/playbooks/update_oslab_template.yaml
echo "Done."
if [ "$STEP" -eq 1 ]
then
echo -n "Continue? [y/n]: "
read ANSWER
[ "$ANSWER" = "n" ] && exit 0
fi
echo "Run vSphere playbooks ... "
cd ${HOME}/playbooks
ansible-playbook update_oslab_template.yaml
ansible-playbook create_oslab_vms.yaml
ansible-playbook change_oslab_vms_mac.yaml
ansible-playbook start_oslab_vms.yaml
echo "Done."
##