Last active
August 29, 2015 14:17
-
-
Save neilmillard/b0412ce0b42271615744 to your computer and use it in GitHub Desktop.
headless puppet
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
#!/bin/sh | |
AWS_ACCESS_KEY="abcdefghijlmnopqrstu" | |
AWS_SECRET_KEY="abcdefghijlmnopqrstuabcdefghijlmnopqrstu" | |
BUCKET_PUPPET="puppet" | |
#export AWS_ACCESS_KEY_ID=$AWS_ACCESS_KEY | |
#export AWS_SECRET_ACCESS_KEY=$AWS_SECRET_KEY | |
#export AWS_DEFAULT_REGION=eu-west-1 | |
# update packages | |
yum -y update | |
#install puppet & s3cmd | |
# ! need to check repo for s3cmd | |
#rpm -ivh http://yum.puppetlabs.com/puppetlabs-release-el-7.noarch.rpm | |
#yes | yum -y install puppet | |
# install puppet manually. first dependancies | |
yum -y install git gcc augeas-devel ruby-devel | |
# then the gems | |
#gem install haml hiera facter json ruby-augeas deep_merge --no-ri --no-rdoc | |
#gem install puppet --version 3.4.3 --no-ri --no-rdoc | |
cd /root | |
rpm -ivh https://yum.puppetlabs.com/el/6/products/x86_64/puppetlabs-release-6-7.noarch.rpm | |
yum install -y puppet | |
yum install -y rubygems | |
#go get the default modules | |
git clone --recursive https://github.com/example42/puppet-modules-nextgen.git /etc/puppet/modules | |
AWSCMDCFG="/root/.aws/credentials" | |
#wget --output-document=$AWSCMDCFG http://s3.amazonaws.com/$BUCKET_PUPPET/credentials | |
sed -i -e "s#__AWS_ACCESS_KEY__#$AWS_ACCESS_KEY#" \ | |
-e "s#__AWS_SECRET_KEY__#$AWS_SECRET_KEY#" $AWSCMDCFG | |
#chmod 400 $AWSCMDCFG | |
aws s3 sync s3://$BUCKET_PUPPET/www /var/www | |
until \ | |
aws s3 sync --no-progress --delete-removed \ | |
s3://$BUCKET_PUPPET/ /etc/puppet/ && \ | |
/usr/bin/puppet apply puppet apply /etc/puppet/manifests/site.pp ; \ | |
do sleep 5 ; done |
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
#!/bin/sh | |
/usr/bin/puppet apply /etc/puppet/manifests/mainrun.pp |
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
#!/bin/sh | |
/usr/local/sbin/puppet-update.sh | |
/usr/local/sbin/puppet-apply.sh |
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
#!/bin/sh | |
BUCKET_PUPPET="puppet" | |
/usr/bin/s3cmd -c /etc/s3cmd.cfg sync --no-progress \ | |
--delete-removed s3://$BUCKET_PUPPET/ /etc/puppet/ |
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
*/30 * * * * sleep `perl -e 'print int(rand(300));'` && /usr/local/sbin/puppet-run.sh > /dev/null |
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
[default] | |
access_key = __AWS_ACCESS_KEY__ | |
secret_key = __AWS_SECRET_KEY__ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment