File tree 1 file changed +65
-0
lines changed
1 file changed +65
-0
lines changed Original file line number Diff line number Diff line change
1
+ #! /bin/sh
2
+ #
3
+ # Prepare UpCloud virtualserver for a Puppet run and then run Puppet.
4
+ #
5
+ # REQUIRES: $PUPPETMASTER variable in init.conf
6
+ #
7
+
8
+ . ./init.conf
9
+
10
+ # ## PREPARATIONS
11
+ PATH=/bin:/usr/bin:/sbin:/usr/sbin
12
+ OS=$( lsb_release -cs)
13
+
14
+ FQDN=` hostname -f`
15
+ HOSTNAME=` hostname -s`
16
+ DOMAIN=` hostname -d`
17
+
18
+ # Temporary files will go to the home directory
19
+ cd ~
20
+
21
+ # ## BASIC SETUP
22
+
23
+ # Install sudo, if it is not present
24
+ which sudo
25
+ if [ $? -ne 0 ]; then
26
+ apt-get install sudo
27
+ fi
28
+
29
+ IP=$( ifconfig eth0 | grep " inet " | awk -F' [: ]+' ' { print $4 }' )
30
+
31
+ HOSTS_LINE=" $IP $FQDN $HOSTNAME "
32
+
33
+ # Remove previous localhost entry
34
+ sudo sed -i ' /127.0.1.1/d' /etc/hosts
35
+ grep " $HOSTS_LINE " /etc/hosts
36
+ if [ $? -ne 0 ]; then
37
+ echo " $HOSTS_LINE " | sudo tee -a /etc/hosts > /dev/null
38
+ fi
39
+
40
+ # ## PUPPET SETUP
41
+
42
+ wget https://apt.puppetlabs.com/puppetlabs-release-$OS .deb
43
+ sudo dpkg -i puppetlabs-release-$OS .deb
44
+ sudo apt-get update
45
+
46
+ sudo apt-get -y install puppet facter
47
+
48
+ PUPPETCONF=" /etc/puppet/puppet.conf"
49
+ sudo cp -n $PUPPETCONF $PUPPETCONF .dist
50
+ sudo cat > $PUPPETCONF << EOF
51
+ [main]
52
+ ssldir=/var/lib/puppet/ssl
53
+ rundir=/var/run/puppet
54
+ stringify_facts=true
55
+
56
+ [agent]
57
+ environment=production
58
+ server=$PUPPETMASTER
59
+ pluginsync=true
60
+ EOF
61
+
62
+
63
+ # Run Puppet
64
+ sudo puppet agent --enable
65
+ sudo puppet agent --test --waitforcert 30
You can’t perform that action at this time.
0 commit comments