Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
#!/usr/bin/env bash
# -- debug
set -xe
if ! [ -x "$(command -v puppet)" ]; then
# -- write hostname correctly
hostname $(curl --silent "http://metadata.google.internal/computeMetadata/v1/instance/attributes/hostname" -H "Metadata-Flavor: Google")
# -- delcare configs
str=$'[main]\ndns=none'
dns=$'# Generated by NetworkManager\nsearch us.internal.com\nnameserver 10.26.10.80\nnameserver 10.28.10.80'
puppet_conf=$'[main]\nserver = uspup-cm.us.domainhere.com'
green_field=$'region_greenfield : true\ngreenfield : true\nregion_appid : splunk\nregion_function : its\region_environment : prd'
# -- disable /etc/resolv.conf being overwritten with str
if [[ ! -e /etc/NetworkManager/conf.d/no-dns.conf ]]; then
echo "$str" > /etc/NetworkManager/conf.d/no-dns.conf
fi
# -- enable repos && update yum
sudo rpm -Uvh https://yum.puppet.com/puppet5-release-el-7.noarch.rpm
sudo yum update -y
# -- export PATH to puppet executable
export PATH=/opt/puppetlabs/bin:$PATH
# -- update DNS
echo "$dns" > /etc/resolv.conf
# -- install puppet agent
sudo yum install puppet-agent -y
# -- update puppet.conf
echo "$puppet_conf" > /etc/puppetlabs/puppet/puppet.conf
echo "$green_field" > /opt/puppetlabs/facter/facts.d/facts.yaml
# -- enable the service
sudo /opt/puppetlabs/bin/puppet resource service puppet ensure=running enable=true
# -- run puppet
sudo /opt/puppetlabs/bin/puppet agent --test --debug
fi
sudo /opt/puppetlabs/bin/puppet agent --test --debug
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment