forked from hashicorp/puppet-bootstrap
-
Notifications
You must be signed in to change notification settings - Fork 2
/
configure.sh
executable file
·74 lines (66 loc) · 2.06 KB
/
configure.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
#!/usr/bin/env bash
#
# Configure puppet.conf
#
set -e
PUPPET_CERTNAME=${PUPPET_CERTNAME:-$(hostname -f)}
PUPPET_ENVIRONMENT=${PUPPET_ENVIRONMENT:-"test"}
PUPPET_ROOT_GROUP=${PUPPET_ROOT_GROUP:-"root"}
case "${PUPPET_ENVIRONMENT}" in
locdev|loctst|locprd|vagrant|all) PUPPET_SERVER=${PUPPET_SERVER:-"localhost"} ;;
esodev|esotst) PUPPET_SERVER=${PUPPET_SERVER:-"uitlpupt10.mcs.miamioh.edu"} ;;
development|test|staging|production|operations|shared_services) PUPPET_SERVER=${PUPPET_SERVER:-"uitlpupp10.mcs.miamioh.edu"} ;;
*)
echo "Unknown/Unsupported PUPPET_ENVIRONMENT." >&2
exit 1
esac
PUPPET_CA_SERVER=${PUPPET_CA_SERVER:-$PUPPET_SERVER}
if [ "$(id -u)" != "0" ]; then
echo "This script must be run as root." >&2
exit 1
fi
if [[ "${PUPPET_COLLECTION}" == "" ]]; then
PCONF="/etc/puppet/puppet.conf"
var_dir='/var/lib/puppet'
log_dir='/var/log/puppet'
run_dir='/var/run/puppet'
ssl_dir='$vardir/ssl'
extra_a_options='
stringify_facts = false'
extra_u_options='
parser = future
stringify_facts = false
ordering = manifest'
else
PCONF="/etc/puppetlabs/puppet/puppet.conf"
var_dir='/opt/puppetlabs/puppet/cache'
log_dir='/var/log/puppetlabs/puppet'
run_dir='/var/run/puppetlabs'
ssl_dir='/etc/puppetlabs/puppet/ssl'
extra_a_options=''
extra_u_options=''
fi
echo "Configuring Puppet..."
cat > ${PCONF} <<-EOF
### File placed by puppet-bootstrap ###
## https://docs.puppet.com/puppet/latest/reference/configuration.html
#
[main]
vardir = ${var_dir}
logdir = ${log_dir}
rundir = ${run_dir}
ssldir = ${ssl_dir}
[agent]
pluginsync = true
report = true
ignoreschedules = true
daemon = false
ca_server = ${PUPPET_CA_SERVER}
certname = ${PUPPET_CERTNAME}
environment = ${PUPPET_ENVIRONMENT}
server = ${PUPPET_SERVER}${extra_a_options}
[user]
environment = ${PUPPET_ENVIRONMENT}${extra_u_options}
EOF
chown root:${PUPPET_ROOT_GROUP} ${PCONF}
chmod 0644 ${PCONF}