-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathOSO3_M5_install_scripted
196 lines (170 loc) · 5.64 KB
/
OSO3_M5_install_scripted
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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
#!/bin/bash
#Start with a CENTOS VM minimal install
#run this script as root on both the Master and Node for openshift
#PLEASE SET BELOW VARIABLES!
fqdn=putyourfqdnhere
fqdn_node01=nodefqdn
nameserver1=nameserverip
nameserver2=nameserverip
nameserver3=nameserverip
ipauser=ipausername
ipapass=ipauserpassword
#Define Text Colors
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
LG='\033[0;37m'
LB='\033[1;34m'
NC='\033[0m' # No Color
TestOSVersion(){
if [ "$(grep -i "Red Hat Enterprise Linux" /etc/redhat-release)" ] || [ "$(grep -i "CentOS" /etc/redhat-release)" ]; then
printf "\n\n${GREEN}Excellent, this is a RHEL based , Centos or Redhat system.${NC}\n\n"
else
printf "\n\n${RED}Uhoh, this system is not a RHEL based Centos or Redhat system, please start with a RHEL based system${NC}\n\n"
exit 1
fi
}
Resolve(){
printf "\n\n${YELLOW}Setting up resolve.${NC}\n\n"
echo "search partshop.lab24.co lab24.co
nameserver $nameserver1
nameserver $nameserver2
nameserver $nameserver3" > /etc/resolv.conf
}
UPDATESystem(){
if rpm -q epel-release | grep "not installed"; then
printf "\n\n${YELLOW}Enabling epel${NC}\n\n"
yum install -y epel-release
ec=$?
Exit
fi
if rpm -q wget tar atop git vim-enhanced system-storage-manager | grep "not installed"; then
printf "\n\n${YELLOW}Installing some tools: atop, wget, vim, git, ssm.${NC}\n\n"
yum install -y wget tar atop git vim system-storage-manager
ec=$?
Exit
fi
printf "\n\n${YELLOW}Updating the system${NC}\n\n"
yum -y update
ec=$?
Exit
}
Reqs(){
# pre-reqs for open shift
if rpm -q ansible libsemanage-python util-linux rubygem-thor | grep "not installed"; then
printf "\n\n${YELLOW}Installing some OpenShift pre-reqs.${NC}\n\n"
yum install -y rubygem-thor rubygem-parseconfig util-linux libsemanage-python ansible
ec=$?
Exit
fi
if rpm -q docker-io | grep "not installed"; then
printf "\n\n${YELLOW}Installing docker.${NC}\n\n"
yum install -y ftp://rpmfind.net/linux/epel/testing/6/x86_64/docker-io-1.6.2-1.el6.x86_64.rpm
yum install -y ftp://195.220.108.108/linux/epel/testing/6/x86_64/docker-io-1.6.2-1.el6.x86_64.rpm
fi
printf "\n\n${YELLOW}Starting docker and enabling it on boot.${NC}\n\n"
systemctl start docker
systemctl enable docker
chkconfig docker on
}
Ssh(){
if [ -f ~/.ssh/id_rsa ]; then
printf "\n\n${YELLOW}ssh-keys exist, not creating new ones${NC}\n\n"
else
printf "\n\n${YELLOW}Generating ssh-keys${NC}\n\n"
#echo statement will overwrite sshkey if it exists
#-N answers with blank for key password
echo -e 'y\n' | ssh-keygen -t rsa -b 4096 -N "" -f ~/.ssh/id_rsa
cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
#ssh-copy-id -i ~/.ssh/id_rsa.pub root@nodeip_or_fqdn
fi
}
#set hostname on openstack
#####edit /etc/cloud/cloud.cfg and comment out set_hostname, update_hostname, update _etc_hosts
#vi /etc/cloud/cloud.cfg
##
Name(){
fqdnrun="fqdnrun.not.set"
if [[ `hostname -s` = *master* ]]; then
printf "\n\n${YELLOW}I believe this is a master, hostname will be set appropriately.${NC}\n\n"
fqdnrun=$fqdn
else
printf "\n\n${YELLOW}I believe this is a node, hostname will be set appropriately.${NC}\n\n"
fqdnrun=$fqdn_node01
fi
printf "\n\n${YELLOW}Setting hostname everywhere I can for consistency${NC}\n\n"
echo $fqdnrun > /etc/hostname
sed -i '/HOSTNAME/d' /etc/sysconfig/network
echo "HOSTNAME="$(echo $fqdnrun) >> /etc/sysconfig/network
sysctl kernel.hostname=$(echo $fqdnrun)
hostnamectl set-hostname $(echo $fqdnrun)
sed -i 's/PEERDNS="yes"/PEERDNS="no"/g' /etc/sysconfig/network-scripts/ifcfg-eth0
sed -i '/HOSTNAME/d' /etc/sysconfig/network-scripts/ifcfg-eth0
echo "DHCP_HOSTNAME="$(echo $fqdnrun)"" >> /etc/sysconfig/network- scripts/ifcfg-eth0
}
#on openstack permit root login in /etc/ssh/sshd_config
#vim /etc/ssh/sshd_config
#sed -i ’s/#PermitRootLogin yes/PermitRootLogin yes/g' /etc/ssh/sshd_config
Ipa(){
printf "\n\n${YELLOW}Adding to IPA${NC}\n\n"
yum -y install ipa-client
ec=$?
Exit
ipa-client-install --enable-dns-updates --mkhomedir -U -p $ipauser -w $ipapass
}
Master(){
if [[ `hostname -s` = *master* ]]; then
printf "\n\n${GREEN}Looks like we're running on the master, treating this as the OSO M5 master!${NC}\n\n"
else
printf "\n\n${YELLOW}Looks like this is a node, exiting to let ansible do it's thing!${NC}\n\n"
exit 0
fi
}
Exit(){
if [[ $ec != 0 ]]; then
printf "\n\n${RED}Something has gone wrong! Error Code: $ec${NC}\n\n"
exit $ec
fi
}
Oso(){
printf "\n\n${YELLOW}Getting Origin M5 Installer${NC}\n\n"
rm -rf openshift-origin*
wget https://github.com/openshift/origin/releases/download/v1.0.0/openshift-origin-v1.0.0-67617dd-linux-amd64.tar.gz && tar -xzf openshift-origin-v1.0.0-67617dd-linux-amd64.tar.gz
ec=$?
Exit
git clone https://github.com/openshift/openshift-ansible.git
ec=$?
Exit
}
Fxa(){
printf "\n\n${YELLOW}Fixing Ansible hosts file${NC}\n\n"
cp openshift-ansible/inventory/byo/hosts /etc/ansible/hosts
sed -i "s/.*-master-.*/$fqdn/" /etc/ansible/hosts
sed -i "s/.*-node.*/$fqdn_node01/" /etc/ansible/hosts
}
Ins(){
#### the below needs to run successfully
#ansible-playbook ~/openshift-ansible/playbooks/byo/openshift-facts.yml
printf "\n\n${YELLOW}Running Openshift Ansible installer${NC}\n\n"
ansible-playbook ~/openshift-ansible/playbooks/byo/config.yml
printf "\n\n${YELLOW}Creating Openshift Router${NC}\n\n"
openshift admin router --create=true --credentials=/etc/openshift/master/openshift-router.kubeconfig
printf "\n\n${YELLOW}Creating Openshift Registry${NC}\n\n"
openshift admin registry --create=true --credentials=/etc/openshift/master/openshift-registry.kubeconfig --mount-host=/var/lib/openshift/docker-registry
}
Strt(){
printf "\n\n${YELLOW}Starting Openshift${NC}\n\n"
openshift start
}
TestOSVersion
UPDATESystem
Resolve
Reqs
Ssh
Name
Ipa
Master
Oso
Fxa
Ins
Strt