Skip to content

Instantly share code, notes, and snippets.

@ageekymonk
Last active August 29, 2015 14:11
Show Gist options
  • Save ageekymonk/a3632cae54cc98855cea to your computer and use it in GitHub Desktop.
Save ageekymonk/a3632cae54cc98855cea to your computer and use it in GitHub Desktop.
awsVagrant
#!/bin/bash
wget https://apt.puppetlabs.com/puppetlabs-release-trusty.deb
dpkg -i puppetlabs-release-trusty.deb
apt-get update
apt-get -y install puppetmaster puppet puppetdb mcollective facter hiera puppetdb-terminus mcollective-client
puppet resource package puppetdb ensure=latest
# -*- mode: ruby -*-
# vi: set ft=ruby :
AWS_PRIVATE_KEY_PATH = 'mykey.pem'
AWS_ACCESS_KEY_ID = 'XXXYYYZZZ'
AWS_SECRET_KEY = 'XXXZZZZYYY'
awsboxes = [
{
:name => 'puppet',
:primary => 'true',
:instance_type => 't2.micro',
:elastic_ip => false,
:ami => 'ami-1711732d',
:username => "ubuntu",
:keypair => 'mykeyname',
:security_groups=> 'sg-11111111',
:region => 'ap-southeast-2',
:subnet_id => 'subnet-1111111',
:initscript => 'puppet.sh'
},
]
# Timeout for the vagrant machine to comeup
AWS_BOX_CONNECT_TIMEOUT = 180
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
# Configure all aws boxes
awsboxes.each do |box|
config.vm.define box[:name], primary: box[:primary] do |boxconfig|
boxconfig.vm.box = "dummy"
boxconfig.vm.box_url = "https://github.com/mitchellh/vagrant-aws/raw/master/dummy.box"
boxconfig.vm.hostname = box[:name]
boxconfig.vm.boot_timeout = AWS_BOX_CONNECT_TIMEOUT
boxconfig.vm.provider :aws do |aws, override|
override.ssh.private_key_path = AWS_PRIVATE_KEY_PATH
override.ssh.username = box[:username]
override.ssh.forward_agent = true
aws.user_data = File.read(box[:initscript])
aws.access_key_id = AWS_ACCESS_KEY_ID
aws.secret_access_key = AWS_SECRET_KEY
aws.keypair_name = box[:keypair]
aws.security_groups = box[:security_groups]
aws.region = box[:region]
# Ubuntu Server 14.04 LTS (HVM), SSD Volume Type
aws.ami = box[:ami]
aws.instance_ready_timeout = AWS_BOX_CONNECT_TIMEOUT
aws.instance_type = box[:instance_type]
aws.elastic_ip = box[:elastic_ip]
aws.subnet_id = box[:subnet_id]
aws.tags = { 'Name' => box[:name] }
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment