Created
February 17, 2014 19:40
-
-
Save gregbuehler/9057465 to your computer and use it in GitHub Desktop.
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 | |
(set -o igncr) 2>/dev/null && set -o igncr; # this comment is needed | |
set -e # stop on errors | |
export ANSIBLE_HOST_KEY_CHECKING=False | |
export ANSIBLE_SSH_ARGS="" | |
export WORKSPACE=/vagrant | |
export ENV_PATH=$WORKSPACE/devops/envs/vagrant | |
export ANSIBLE_ROLES_PATH=/vagrant/devops/roles | |
PLAYBOOK=$1 | |
TARGET=`hostname -s` | |
CMD="ansible-playbook -u devops -vvvv -i $ENV_PATH $PLAYBOOK --limit $TARGET -c local" | |
echo $CMD | |
$CMD | |
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
# -*- mode: ruby -*- | |
# vi: set ft=ruby : | |
VAGRANTFILE_API_VERSION = "2" | |
boxes = [ | |
{ | |
:hostname => "redacted", | |
:ip => 'redacted', | |
:ports => [ | |
{ :src => 1234, :dest => 1234 } | |
], | |
:playbooks => [ | |
'/vagrant/devops/redacted.yml', | |
'/vagrant/devops/redacted.yml', | |
] | |
}, | |
] | |
default_deploy = { | |
:box => "redacted", | |
:box_url => "redacted", | |
:domain => "redacted", | |
:ram => 1024 | |
} | |
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| | |
boxes.each do |box| | |
hostname = box[:hostname] | |
config.vm.define hostname do |box_config| | |
box_config.vm.box = default_deploy[:box] | |
box_config.vm.box_url = default_deploy[:box_url] | |
box_config.vm.guest = 'redhat' | |
box_config.vm.hostname = box[:hostname] + '.' + default_deploy[:domain] | |
box_config.vm.network "private_network", ip: box[:ip] | |
box[:ports].each do |port| | |
box_config.vm.network "forwarded_port", guest: port[:src], host: port[:dest] | |
end | |
box_config.vm.provider "virtualbox" do |v| | |
v.customize [ | |
'modifyvm', :id, | |
'--name', box[:hostname], | |
'--memory', default_deploy[:ram].to_s | |
] | |
end | |
box[:playbooks].each do |playbook| | |
box_config.vm.provision "shell" do |s| | |
s.inline = "sh /vagrant/run_playbook.sh #{playbook}" | |
end | |
end # end playbook | |
end # end box_config | |
end # end box | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment