Created
September 5, 2019 05:13
-
-
Save simbalinux/34d4a777566ab6b0dc57ca61a28e45cc to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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