forked from atomia/puppet-atomia
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup-puppet-atomia
executable file
·106 lines (81 loc) · 2.79 KB
/
setup-puppet-atomia
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
wget https://apt.puppetlabs.com/puppetlabs-release-trusty.deb
sudo dpkg -i puppetlabs-release-trusty.deb
sudo apt-get update
sudo apt-get install -y puppetmaster puppet git apache2-utils curl rubygems-integration build-essential libmysqlclient-dev ruby-dev
sudo apt-get install -y puppetdb puppetdb-terminus
echo "127.0.0.1 puppet" >> /etc/hosts
echo "127.0.0.1 puppetdb" >> /etc/hosts
gem install --no-rdoc --no-ri hiera-mysql hiera-mysql-backend mysql mysql2
cd /etc/puppet
## Setup MYSQL and add hiera user and database
if [ -z ${HIERA_USER_PASSWORD+x} ]; then
HIERA_USER_PASSWORD=`date +%s | sha256sum | base64 | head -c 16`
fi
SERVER_FQDN=`facter fqdn`
mysql --defaults-file=/etc/mysql/debian.cnf -e "GRANT USAGE ON *.* TO 'hierauser'@'localhost'; DROP USER 'hierauser'@'localhost';"
mysql --defaults-file=/etc/mysql/debian.cnf -e "CREATE USER 'hierauser'@'localhost' IDENTIFIED BY '${HIERA_USER_PASSWORD}'; GRANT ALL PRIVILEGES ON hiera.* TO 'hierauser'@'localhost';FLUSH PRIVILEGES;"
## Setup PuppetDB
echo "[main]
server = ${SERVER_FQDN}
port = 8081
soft_write_failure = false" > /etc/puppet/puppetdb.conf
mkdir -p /etc/puppet/atomia/service_files
echo "mod \"atomia\", :git =>\"git://github.com/atomia/puppet-atomia.git\", :ref => \"master\" " > /etc/puppet/Puppetfile
cd /etc/puppet
gem install --no-rdoc --no-ri librarian-puppet
HOME=/root librarian-puppet install
cp /etc/puppet/modules/atomia/files/default_files/* /etc/puppet/atomia/service_files/
mkdir -p /etc/puppet/manifests/
echo "
node default {
hiera_include('classes')
}
" > /etc/puppet/manifests/site.pp
echo "---
:backends:
- yaml
- mysql
:yaml:
:datadir: /etc/puppet/hieradata
:mysql:
:host: localhost
:user: hierauser
:pass: ${HIERA_USER_PASSWORD}
:database: hiera
:query: SELECT val FROM configuration WHERE var='%{key}'
:hierarchy:
- \"%{::atomia_role_1}\"
- \"%{::atomia_role_2}\"
- \"%{::atomia_role_3}\"
- \"%{::atomia_role_4}\"
- \"%{::atomia_role_5}\"
- bootstrap
:logger: console
" > /etc/puppet/hiera.yaml
echo "[atomiacerts]
path /etc/puppet/atomiacerts
allow *
[atomia]
path /etc/puppet/atomia
allow *" > /etc/puppet/fileserver.conf
echo "[main]
logdir=/var/log/puppet
vardir=/var/lib/puppet
ssldir=/var/lib/puppet/ssl
rundir=/var/run/puppet
factpath=$vardir/lib/facter
parser = future
[master]
# These are needfed when the puppetmaster is run by passenger
# and can safely be removed if webrick is used.
ssl_client_header = SSL_CLIENT_S_DN
ssl_client_verify_header = SSL_CLIENT_VERIFY
autosign = true
storeconfigs = true
storeconfigs_backend = puppetdb
reports = store,puppetdb" > /etc/puppet/puppet.conf
mv modules/atomia/examples/hieradata/ /etc/puppet/hieradata/
sudo update-rc.d puppetdb defaults
sudo service puppetdb start
/etc/init.d/puppetmaster restart
echo "ALL DONE!"