Skip to content

Instantly share code, notes, and snippets.

@ezarko
Last active December 18, 2015 23:58
Show Gist options
  • Save ezarko/cda14960eb14058a25a5 to your computer and use it in GitHub Desktop.
Save ezarko/cda14960eb14058a25a5 to your computer and use it in GitHub Desktop.
CloudFormation bootstraping for puppet
# 1) set up EPEL
rpm -Uvh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
# 2) install some dependencies
yum install -y pystache python-daemon python-lockfile
# 3) install aws-cfn-bootstrap
rpm -Uvh http://yum_server.example.com/yum/noarch/aws-cfn-bootstrap-1.4-8.3.el6.noarch.rpm
# 4) run cfn-init or signal error
/opt/aws/bin/cfn-init --region <Region> -s <StackId> -r db1 || /opt/aws/bin/cfn-signal -e 1 -r 'Failed to initialize server role using cfn-init' '<WaitHandle>'
# 5) signal success
/opt/aws/bin/cfn-signal -e $? '<WaitHandle>'
#cloud-config
hostname: hostname
fqdn: hostname.example.com
manage_etc_hosts: true
#cloud-config
mounts:
- ["ephemeral0","none","swap","sw","0","0"]
# 0) run bootcmds
mkswap /dev/xvdb
swapon /dev/xvdb
{
"AWS::CloudFormation::Init" : {
"config" : {
"packages" : {
"rpm" : {
"puppetlabs" : "https://yum.puppetlabs.com/puppetlabs-release-el-6.noarch.rpm"
},
"yum" : {
"gcc" : [],
"make" : [],
"puppet" : [],
"ruby-devel" : [],
"rubygems" : []
},
"rubygems" : {
"json" : []
}
},
"files" : {
"/etc/puppet/puppet.conf" : {
"content" : "[main]\n logdir=/var/log/puppet\n rundir=/var/run/puppet\n ssldir=$vardir/ssl\n pluginsync=true\n environment=production\n[agent]\n classfile=$vardir/classes.txt\n localconfig=$vardir/localconfig\n server=puppet.dev.trinet.com\n",
"group" : "root",
"mode" : "000644",
"owner" : "root"
}
},
"commands" : {
"00_enable_puppet" : {
"command" : "/usr/bin/puppet agent --enable"
},
"01_puppet" : {
"command" : "/usr/bin/puppet agent --onetime --verbose --ignorecache --no-daemonize --no-usecacheonfailure --no-splay --show_diff"
},
"02_puppet" : {
"command" : "/usr/bin/puppet agent --onetime --verbose --ignorecache --no-daemonize --no-usecacheonfailure --no-splay --show_diff"
}
},
"services" : {
"sysvinit" : {
"puppet" : {
"enabled" : "true",
"ensureRunning" : "true"
}
}
}
}
},
"Puppet" : {
"some_var" : "some_value"
}
}
Content-Type: multipart/mixed; boundary="----------=_1419033947-57534-0"
MIME-Version: 1.0
------------=_1419033947-57534-0
Content-Disposition: inline
Content-Transfer-Encoding: binary
Content-Type: text/cloud-config
<CLOUD CONFIG GOES HERE>
------------=_1419033947-57534-0
Content-Disposition: inline
Content-Transfer-Encoding: binary
Content-Type: text/x-shellscript
<BASH SCRIPT GOES HERE>
------------=_1419033947-57534-0--
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment