-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathmasterInstaller.sh
209 lines (180 loc) · 5.92 KB
/
masterInstaller.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
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
197
198
199
200
201
202
203
204
205
206
207
208
209
#!/bin/bash
# Puppet Master Install with The Foreman 1.5 on Debian Wheezy 7.5
# Author: John McCarthy
# <http://www.midactstech.blogspot.com> <https://www.github.com/Midacts>
# Date: 28th of April, 2015
# Version 1.4
#
# To God only wise, be glory through Jesus Christ forever. Amen.
# Romans 16:27, I Corinthians 15:1-4
#---------------------------------------------------------------
######## FUNCTIONS ########
function setHostname()
{
# Edits the /etc/hosts file
IP=`hostname -I`
Hostname=`hostname`
FQDN=`hostname -f`
echo -e "127.0.0.1 localhost localhosts.localdomain $FQDN\n$IP $FQDN $Hostname puppet" > /etc/hosts
}
function puppetRepos()
{
# Gets the latest puppet repos
echo
echo -e '\e[01;34m+++ Getting repositories...\e[0m'
wget http://apt.puppetlabs.com/puppetlabs-release-wheezy.deb
dpkg -i puppetlabs-release-wheezy.deb
apt-get update
echo -e '\e[01;37;42mThe Latest Puppet Repos have been acquired!\e[0m'
}
function installPuppet()
{
# Installs the latest version of puppetmaster
echo
echo -e '\e[01;34m+++ Installing Puppet Master...\e[0m'
apt-get install puppetmaster-passenger -y
echo -e '\e[01;37;42mThe Puppet Master has been installed!\e[0m'
}
function enablePuppet()
{
# Enables the puppetmaster service to be set to ensure it is running
echo
echo -e '\e[01;34m+++ Enabling Puppet Master Service...\e[0m'
puppet resource service puppetmaster ensure=running enable=true
echo -e '\e[01;37;42mThe Puppet Master Service has been initiated!\e[0m'
}
function foremanRepos()
{
# Gets the latest foreman repos
echo
echo -e '\e[01;34m+++ Getting repositories...\e[0m'
echo "deb http://deb.theforeman.org/ wheezy 1.7" > /etc/apt/sources.list.d/foreman.list
echo "deb http://deb.theforeman.org/ plugins 1.7" >> /etc/apt/sources.list.d/foreman.list
wget -q http://deb.theforeman.org/pubkey.gpg -O- | apt-key add -
apt-get update
echo -e '\e[01;37;42mThe Latest Foreman Repos have been acquired!\e[0m'
}
function installForeman()
{
# Downloads the foreman-installer
echo
echo -e '\e[01;34m+++ Installing The Foreman...\e[0m'
apt-get install foreman-installer -y
echo -e '\e[01;37;42mThe Foreman Installer has been downloaded!\e[0m'
# Stars foreman-installer
echo
echo -e '\e[01;34mInitializing The Foreman Installer...\e[0m'
echo "-------------------------------------"
sleep 1
echo -e '\e[33mMake any additional changes you would like\e[0m'
sleep 1
echo -e '\e[33mSelect option "24" and hit ENTER to run the install\e[0m'
sleep 1
echo
echo -e '\e[97mHere\e[0m'
sleep .5
echo -e '\e[97mWe\e[0m'
sleep .5
echo -e '\e[01;97;42mG O ! ! ! !\e[0m'
foreman-installer -i -v
# Sets foreman and foreman-proxy services to start on boot
sed -i 's/START=no/START=yes/g' /etc/default/foreman
echo "START=yes" >> /etc/default/foreman-proxy
# Sets it so you the puppetmaster and puppet services starts on boot
sed -i 's/START=no/START=yes/g' /etc/default/puppet
# Makes changes for Puppet 3.6.2 deprecation warning
#sed -i '0,/\[main\]/s/\[main\]/&\n # Puppet 3.6.2 Modification\n environmentpath=$confdir\/environments\n/g' /etc/puppet/puppet.conf
#sed -i '/\[development\]/d' /etc/puppet/puppet.conf
#sed -i '/\[production\]/d' /etc/puppet/puppet.conf
#sed -i '/modulepath/d' /etc/puppet/puppet.conf
#sed -i '/config_version/d' /etc/puppet/puppet.conf
# Restarts the foreman and foreman-proxy services
service foreman restart
service foreman-proxy restart
echo -e '\e[01;37;42mThe Foreman has been installed!\e[0m'
# Restarts the apache2 service
echo
echo -e '\e[01;34m+++ Restarting the apache2 service...\e[0m'
service apache2 restart
echo -e '\e[01;37;42mThe apache2 service has been restarted!\e[0m'
}
function doAll()
{
# Calls the setHostname function
echo
echo -e "\e[33m=== Set Machine's Hostname for Puppet Runs ? [RECOMMENDED] (y/n)\e[0m"
read yesno
if [ "$yesno" = "y" ]; then
setHostname
fi
# Calls the puppetRepos function
echo
echo -e "\e[33m=== Get Latest Puppet Repos ? (y/n)\e[0m"
read yesno
if [ "$yesno" = "y" ]; then
puppetRepos
fi
# Calls the installPuppet function
echo
echo -e "\e[33m=== Install Puppet Master ? (y/n)\e[0m"
read yesno
if [ "$yesno" = "y" ]; then
installPuppet
fi
# Calls the enablePuppet function
echo
echo -e "\e[33m=== Enable Puppet Master Service ? (y/n)\e[0m"
read yesno
if [ "$yesno" = "y" ]; then
enablePuppet
fi
# Calls the foremanRepos function
echo
echo -e "\e[33m=== Get Latest Foreman Repos ? (y/n)\e[0m"
read yesno
if [ "$yesno" = "y" ]; then
foremanRepos
fi
# Calls the installForeman function
echo
echo -e "\e[33m=== Install The Foreman ? (y/n)\e[0m"
read yesno
if [ "$yesno" = "y" ]; then
installForeman
fi
# End of Script Congratulations, Farewell and Additional Information
clear
farewell=$(cat << EOZ
\e[01;37;42mWell done! You have completed your Puppet Master and Foreman Installation! \e[0m
\e[01;39mProceed to your Foreman web UI, https://fqdn\e[0m
\e[01;39mForeman Default Credentials:\e[0m
\e[34mUsername\e[0m\e[01;39m: admin\e[0m
\e[34mPassword\e[0m\e[01;39m: changeme\e[0m
\e[30;01mCheckout similar material at midactstech.blogspot.com and github.com/Midacts\e[0m
\e[01;37m########################\e[0m
\e[01;37m#\e[0m \e[31mI Corinthians 15:1-4\e[0m \e[01;37m#\e[0m
\e[01;37m########################\e[0m
EOZ
)
#Calls the End of Script variable
echo -e "$farewell"
echo
echo
exit 0
}
# Check privileges
[ $(whoami) == "root" ] || die "You need to run this script as root."
# Welcome to the script
clear
welcome=$(cat << EOA
\e[01;37;42mWelcome to Midacts Mystery's Puppet Master Installer!\e[0m
EOA
)
# Calls the welcome variable
echo -e "$welcome"
# Calls the doAll function
case "$go" in
* )
doAll ;;
esac
exit 0