Created
February 5, 2016 05:15
-
-
Save flashvoid/5c9ed7a5094fe52f88a6 to your computer and use it in GitHub Desktop.
Vagrantfile
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
# -*- mode: ruby -*- | |
# vi: set ft=ruby : | |
Vagrant.configure(2) do |config| | |
# Common VM configuration | |
config.vm.box = "ubuntu/trusty64" | |
config.vm.box_url = "http://cloud-images.ubuntu.com/vagrant/trusty/current/trusty-server-cloudimg-amd64-vagrant-disk1.box" | |
config.vm.synced_folder '.', '/home/vagrant/romana' | |
config.vm.provision "shell", inline: <<-EOF | |
apt-get install -y python-apt python-pip python-dev python-netaddr && pip install awscli ansible | |
EOF | |
# --- | |
# Compute-specific VM configuration | |
config.vm.define "jbrendel-compute01" do |compute| | |
config.vm.hostname = "ip-192-168-99-11" | |
compute.vm.network "private_network", ip: "192.168.99.11" | |
compute.vm.provider "virtualbox" do |vb| | |
vb.name = "jbrendel-compute01" | |
vb.memory = "1024" | |
vb.customize ["modifyvm", :id, "--natdnshostresolver1", "on", "--natnet1", "192.168/16"] | |
end | |
compute.vm.provision "shell", inline: <<-EOF | |
if ! test -f /home/vagrant/.ssh/id_rsa; then | |
wget https://raw.githubusercontent.com/mitchellh/vagrant/master/keys/vagrant -O /home/vagrant/.ssh/id_rsa | |
chmod 600 /home/vagrant/.ssh/id_rsa* | |
chown vagrant:vagrant /home/vagrant/.ssh/id_rsa* | |
ssh-keygen -yf /home/vagrant/.ssh/id_rsa >> /home/vagrant/.ssh/authorized_keys | |
fi | |
EOF | |
end | |
# --- | |
# Controller-specific VM configuration | |
config.vm.define "jbrendel-controller" do |controller| | |
config.vm.hostname = "ip-192-168-99-10" | |
controller.vm.network "private_network", ip: "192.168.99.10" | |
controller.vm.provider "virtualbox" do |vb| | |
vb.name = "jbrendel-controller" | |
vb.memory = "1024" | |
vb.customize ["modifyvm", :id, "--natdnshostresolver1", "on", "--natnet1", "192.168/16"] | |
end | |
controller.vm.provision "shell", inline: <<-EOF | |
if ! test -f /home/vagrant/.ssh/id_rsa; then | |
wget https://raw.githubusercontent.com/mitchellh/vagrant/master/keys/vagrant -O /home/vagrant/.ssh/id_rsa | |
chmod 600 /home/vagrant/.ssh/id_rsa* | |
chown vagrant:vagrant /home/vagrant/.ssh/id_rsa* | |
ssh-keygen -yf /home/vagrant/.ssh/id_rsa >> /home/vagrant/.ssh/authorized_keys | |
fi | |
if ! test -f /home/vagrant/romana/hosts.ini; then | |
echo -e "[stack-nodes]\n 192.168.99.10\n 192.168.99.11\n \n [controller]\n 192.168.99.10\n \n [computes]\n 192.168.99.11\n " > /home/vagrant/romana/hosts.ini | |
fi | |
sudo su - vagrant -c "cd /home/vagrant/romana/ && ansible -i hosts.ini -m ping all" | |
sudo su - vagrant -c "cd /home/vagrant/romana/ && ansible-playbook -i hosts.ini config_vagrant.yml" | |
EOF | |
end | |
# --- | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment