Skip to content

Commit

Permalink
Merge pull request #72 from StackStorm/rhel_VagrantFile_support
Browse files Browse the repository at this point in the history
Vagrantfile update for Multi VM support
  • Loading branch information
humblearner authored Jan 6, 2017
2 parents cde7524 + 8656f91 commit d745d14
Showing 1 changed file with 58 additions and 28 deletions.
86 changes: 58 additions & 28 deletions Vagrantfile
Original file line number Diff line number Diff line change
@@ -1,42 +1,72 @@
# -*- mode: ruby -*-
# vi: set ft=ruby :

HOSTNAME = 'ansible-st2'

VAGRANTFILE_API_VERSION = '2'
VIRTUAL_MACHINES = {
:ubuntu14 => {
:hostname => 'ubuntu14',
:box => 'ubuntu/trusty64',
},
:ubuntu16 => {
:hostname => 'ubuntu16',
:box => 'ubuntu/xenial64',
},
:centos6 => {
:hostname => 'centos6',
:box => 'centos/6',
},
:centos7 => {
:hostname => 'centos7',
:box => 'centos/7',
},
}


Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = 'ubuntu/xenial64'
config.vm.hostname = "#{HOSTNAME}"
config.vm.network "forwarded_port", guest: 22, host: 2200, auto_correct: true
config.ssh.shell = "bash -c 'BASH_ENV=/etc/profile exec bash'"
config.ssh.forward_agent = true

config.vm.provider :virtualbox do |vb|
vb.name = "#{HOSTNAME}"
vb.customize ['modifyvm', :id, '--memory', '2048']
end
VIRTUAL_MACHINES.each do |name, cfg|
config.vm.define name do |vm_config|
vm_config.vm.hostname = cfg[:hostname]
vm_config.vm.box = cfg[:box]

if Vagrant.has_plugin?('vagrant-cachier')
config.cache.scope = :box
end
vm_config.vm.provider :virtualbox do |vb|
vb.name = "#{cfg[:hostname]}"
vb.customize ['modifyvm', :id, '--memory', '2048']
end

if Vagrant.has_plugin?('vagrant-hostmanager')
config.hostmanager.enabled = false
config.hostmanager.manage_host = true
config.hostmanager.ignore_private_ip = false
config.hostmanager.include_offline = true
config.hostmanager.aliases = ["www.#{HOSTNAME}"]
config.vm.provision :hostmanager
end
if Vagrant.has_plugin?('vagrant-cachier')
vm_config.cache.scope = :box
end

# Install Ansible native packages so the Ansible provisioner will work on systems
# without Python 2.7 (i.e. Xenial)
config.vm.provision "shell",
inline: "sudo apt-add-repository -y ppa:ansible/ansible; sudo apt-get update; sudo apt-get install -y ansible"
if Vagrant.has_plugin?('vagrant-hostmanager')
vm_config.hostmanager.enabled = false
vm_config.hostmanager.manage_host = true
vm_config.hostmanager.ignore_private_ip = false
vm_config.hostmanager.include_offline = true
vm_config.hostmanager.aliases = ["www.#{cfg[:hostname]}"]
vm_config.vm.provision :hostmanager
end

config.vm.provision :ansible do |ansible|
ansible.playbook = "requirements.yml"
end
config.vm.provision :ansible do |ansible|
ansible.playbook = "stackstorm.yml"
if vm_config.vm.hostname.include? "ubuntu"
# Install Ansible native packages so the Ansible provisioner will work on systems
# without Python 2.7 (i.e. Xenial)
vm_config.vm.provision "shell",
inline: "sudo apt-add-repository -y ppa:ansible/ansible; sudo apt-get update; sudo apt-get install -y ansible"
end
if vm_config.vm.hostname.include? "centos"
vm_config.vm.provision "shell",
inline: "sudo yum -y install epel-release; sudo yum -y install ansible git"
end

vm_config.vm.provision :ansible do |ansible|
ansible.playbook = "requirements.yml"
end
vm_config.vm.provision :ansible do |ansible|
ansible.playbook = "stackstorm.yml"
end
end
end
end

0 comments on commit d745d14

Please sign in to comment.