forked from sensu/sensu-puppet
-
Notifications
You must be signed in to change notification settings - Fork 0
/
provision_basic_debian.sh
63 lines (51 loc) · 1.78 KB
/
provision_basic_debian.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
#!/bin/bash
# using this instead of "rpm -Uvh" to resolve dependencies
function deb_install() {
package=$(echo $1 | awk -F "/" '{print $NF}')
wget --quiet $1
dpkg -i ./$package
rm -f $package
}
export DEBIAN_FRONTEND=noninteractive
if [ -f /etc/lsb-release ]; then
# ubuntu
. /etc/lsb-release
CODENAME=$DISTRIB_CODENAME
else
# debian
CODENAME=$(grep ^VERSION= /etc/os-release | awk -F \( '{print $2}' | awk -F \) '{print $1}')
apt-get -y install apt-transport-https
apt-get update
fi
# Debian 9 (stretch) complains about the dirmngr package missing.
if [ "${CODENAME}" == 'stretch' ]; then
apt-get -y install dirmngr
fi
apt-key adv --fetch-keys http://apt.puppetlabs.com/DEB-GPG-KEY-puppet
apt-get -y install wget
# install and configure puppet
deb_install http://apt.puppetlabs.com/puppet6-release-${CODENAME}.deb
apt-get update
apt-get -y install puppet-agent
ln -s /opt/puppetlabs/puppet/bin/puppet /usr/bin/puppet
# suppress default warnings for deprecation
cat > /etc/puppetlabs/puppet/hiera.yaml <<EOF
---
version: 5
hierarchy:
- name: Common
path: common.yaml
defaults:
data_hash: yaml_data
datadir: hieradata
EOF
# use local sensu module
puppet resource file /etc/puppetlabs/code/environments/production/modules/sensu ensure=link target=/vagrant
# setup module dependencies
puppet module install puppetlabs/stdlib --version ">= 5.1.0 < 8.0.0"
puppet module install puppetlabs/apt --version ">= 5.0.1 < 9.0.0"
puppet module install richardc-datacat --version ">= 0.6.2 < 2.0.0"
puppet resource host sensu-backend.example.com ensure=present ip=192.168.52.10 host_aliases=sensu-backend
puppet config set --section main certname sensu-agent
[ ! -d /etc/puppetlabs/puppet/ssl ] && mkdir /etc/puppetlabs/puppet/ssl
cp -r /vagrant/tests/ssl/* /etc/puppetlabs/puppet/ssl/