-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.sh
executable file
·140 lines (111 loc) · 2.85 KB
/
install.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
#!/bin/bash -eu
hostname=${1?"Usage: $0 <hostname> <puppet-dir>"}
vardir=${2?"Usage: $0 <hostname> <puppet-dir>"}
cat > /etc/hostname <<EOF
$hostname
EOF
yum -y update
# Puppetlabs Repos
rpm -ivh https://yum.puppetlabs.com/puppetlabs-release-el-7.noarch.rpm
: '
Puppet Master
Der Puppet Master wird mit wie folgt Installiert:
- puppet-server (puppet master)
- puppetdb
- postgresql (Backend für PuppetDB)
'
yum install -y puppet-server.noarch postgresql-server.x86_64 postgresql-contrib.x86_64
puppet resource package puppet-server ensure=latest
puppet resource package puppetdb ensure=latest
puppet resource package puppetdb-terminus ensure=latest
# Puppet Setup
cat > /etc/puppet/puppet.conf <<EOF
[main]
vardir = $vardir
logdir = /var/log/puppet
rundir = /var/run/puppet
ssldir = \$vardir/ssl
dns_alt_names = puppet,$hostname
[agent]
classfile = \$vardir/classes.txt
localconfig = \$vardir/localconfig
[master]
autosign = true
storeconfigs = true
storeconfigs_backend = puppetdb
EOF
cat > /etc/puppet/routes.yaml <<EOF
---
master:
facts:
terminus: puppetdb
cache: yaml
EOF
# PuppetDB Setup
cat > /etc/puppet/puppetdb.conf <<EOF
[main]
server = puppet
port = 8081
EOF
cat > /etc/puppetdb/conf.d/config.ini <<EOF
[global]
vardir = /var/lib/puppetdb
logging-config = /etc/puppetdb/logback.xml
[command-processing]
EOF
cat > /etc/puppetdb/conf.d/database.ini <<EOF
[database]
classname = org.postgresql.Driver
subprotocol = postgresql
subname = //localhost:5432/puppetdb
username = puppetdb
log-slow-statements = 10
EOF
cat > /etc/puppetdb/conf.d/jetty.ini <<EOF
[jetty]
ssl-host = 0.0.0.0
ssl-port = 8081
ssl-key = /etc/puppetdb/ssl/private.pem
ssl-cert = /etc/puppetdb/ssl/public.pem
ssl-ca-cert = /etc/puppetdb/ssl/ca.pem
EOF
cat > /etc/puppetdb/conf.d/repl.ini <<EOF
[repl]
enabled = false
type = nrepl
port = 8082
EOF
cat > /etc/puppet/manifests/site.pp <<EOF
file { "/tmp/puppet":
ensure => "present",
content => generate('/bin/date', '+%s'),
}
service { "puppet":
enable => "true",
ensure => "running",
}
Package {
allow_virtual => true,
}
EOF
chown -R puppet:puppet $(puppet config print confdir) /var/lib/puppet
# PostgreSQL Setup
mkdir /etc/puppet/database
chown postgres:postgres /etc/puppet/database
cat > /etc/systemd/system/postgresql.service <<EOF
.include /lib/systemd/system/postgresql.service
[Service]
Environment=PGDATA=/etc/puppet/database
EOF
systemctl enable postgresql.service
su postgres -c "initdb -D /etc/puppet/database/"
sleep 5
systemctl start postgresql.service
sleep 5
su postgres -c "createuser -DRS puppetdb"
su postgres -c "createdb -E UTF8 -O puppetdb puppetdb"
su postgres -c "psql puppetdb -c 'create extension pg_trgm'"
systemctl enable puppetmaster.service
systemctl start puppetmaster.service
puppetdb ssl-setup
puppet resource service puppetdb ensure=running enable=true