forked from atomia/puppet-atomia
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup-puppet-atomia
95 lines (70 loc) · 2.4 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
sudo apt-get update
apt-get install -y puppetmaster puppet git apache2-utils curl rubygems-integration build-essential libmysqlclient-dev ruby-dev
echo "127.0.0.1 puppet" >> /etc/hosts
puppet agent --enable
puppet agent --test
gem install hiera-mysql hiera-mysql-backend mysql mysql2
cd /etc/puppet
## Setup MYSQL and add hiera user and database
if [ -z ${MYSQL_ROOT_PASSWORD+x} ]; then
MYSQL_ROOT_PASSWORD=`date +%s | sha256sum | base64 | head -c 16 ; echo`
fi
if [ -z ${HIERA_USER_PASSWORD+x} ]; then
HIERA_USER_PASSWORD=`date +%s | sha256sum | base64 | head -c 16 ; echo`
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 puppet_atomia.* TO 'hierauser'@'localhost';FLUSH PRIVILEGES;"
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 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: puppet_atomia
:query: SELECT val FROM configuration WHERE var='%{key}' AND env='%{environment}'
:hierarchy:
- \"%{::atomia_role_1}\"
- \"%{::atomia_role_2}\"
- \"%{::atomia_role_3}\"
- \"%{::atomia_role_4}\"
- \"%{::atomia_role_5}\"
: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]
ssl_client_header = SSL_CLIENT_S_DN
ssl_client_verify_header = SSL_CLIENT_VERIFY
autosign = true
reports = store" > /etc/puppet/puppet.conf
cp -r modules/atomia/examples/hieradata/ /etc/puppet/hieradata/
/etc/init.d/puppetmaster restart
echo "ALL DONE!"