Created
March 26, 2016 12:55
-
-
Save nvd/5edc7edeae6e31b8dd08 to your computer and use it in GitHub Desktop.
Puppet Single Node Setup
This file contains 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
#!/bin/bash | |
#This script lists all commands for setting up an ubuntu instance with puppet master and agent | |
sudo su | |
export LOCAL_HOSTNAME=$(wget -qO- http://instance-data/latest/meta-data/local-hostname) | |
apt-get update | |
apt-get install -y puppet puppetmaster apache2 | |
puppet agent --enable | |
mkdir /opt/hiera_data | |
cat >> /opt/hiera_data/common.yaml << EOF | |
--- | |
hiera_override_test: true | |
EOF | |
cat >> /etc/puppet/hiera.yaml << EOF | |
--- | |
:backends: | |
- yaml | |
:yaml: | |
:datadir: /opt/hiera_data | |
:hierarchy: | |
- common | |
EOF | |
cat >> /etc/puppet/manifests/site.pp << EOF | |
node '$(echo $LOCAL_HOSTNAME)' { | |
\$yaml_backend = hiera('hiera_override_test', 'false') | |
notify { "YAML backend => \$yaml_backend": } | |
} | |
EOF | |
cat >> /etc/puppet/puppet.conf << EOF | |
[agent] | |
server = $(echo $LOCAL_HOSTNAME) | |
environment = production | |
EOF | |
cat >> /etc/hosts << EOF | |
127.0.0.1 $(echo $LOCAL_HOSTNAME) | |
EOF | |
# Test | |
hiera -c /etc/puppet/hiera.yaml "hiera_override_test" -d | |
puppet agent -tv |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment