Ansible: Vagrant: Add vbox support

pull/6/head
Eric Paris 2015-07-13 10:21:04 -04:00
parent 36e991742b
commit dda42add54
3 changed files with 22 additions and 49 deletions

View File

@ -4,7 +4,7 @@ This deployer sets up a vagrant cluster and installs kubernetes with flannel on
## Before you start !
You will need a functioning vagrant provider. Currently supported are openstack.
You will need a functioning vagrant provider. Currently supported are openstack and virtualbox.
## USAGE
@ -44,4 +44,7 @@ To use the vagrant openstack provider you will need
For vagrant (1.7.2) does not seem to ever want to pick openstack as the provider. So you will need to tell it to use openstack explicitly.
### VirtualBox
Nothing special with VirtualBox. Hopefully `vagrant up` just works.
[![Analytics](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/contrib/ansible/vagrant/README.md?pixel)]()

View File

@ -58,6 +58,18 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
os.server_name = n.vm.hostname
end
def set_vbox(vb, config)
config.vm.box = "chef/centos-7.0"
config.vm.network "private_network", type: "dhcp"
vb.gui = false
vb.memory = 2048
vb.cpus = 2
# Use faster paravirtualized networking
vb.customize ["modifyvm", :id, "--nictype1", "virtio"]
vb.customize ["modifyvm", :id, "--nictype2", "virtio"]
end
config.vm.synced_folder ".", "/vagrant", disabled: true
nodes = Array.new()
@ -70,6 +82,9 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
n.vm.provider :openstack do |os, override|
set_openstack(os, override, n)
end
n.vm.provider :virtualbox do |vb, override|
set_vbox(vb, override)
end
end
end
@ -89,6 +104,9 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
n.vm.provider :openstack do |os, override|
set_openstack(os, override, n)
end
n.vm.provider :virtualbox do |vb, override|
set_vbox(vb, override)
end
# This set up the vagrant hosts before we run the main playbook
# Today this just creates /etc/hosts so machines can talk via their

View File

@ -1,48 +0,0 @@
# -*- mode: ruby -*-
# vi: set ft=ruby :
# TODO: This is deprecated, as we will be merging vbox support to the main Vagrantfile soon enough !
#
# All Vagrant configuration is done below. The "2" in Vagrant.configure
# configures the configuration version (we support older styles for
# backwards compatibility). Please don't change it unless you know what
# you're doing.
Vagrant.configure(2) do |config|
config.vm.box = "chef/centos-7.0"
# config.vm.network "public_network"
config.vm.define "master", primary: true do |master|
master.vm.hostname = "master.vms.local"
master.vm.network "private_network", ip: "192.168.1.100"
end
(1..1).each do |i|
config.vm.define "node-#{i}" do |node|
node.vm.hostname = "node-#{i}.vms.local"
node.vm.network "private_network", ip: "192.168.1.1#{i}"
node.vm.provision :ansible do |ansible|
ansible.host_key_checking = false
ansible.extra_vars = {
ansible_ssh_user: 'vagrant',
ansible_ssh_pass: 'vagrant',
user: 'vagrant'
}
#ansible.verbose = 'vvv'
ansible.playbook = "../cluster.yml"
ansible.inventory_path = "vinventory"
ansible.limit = 'all'
end
end
end
config.vm.provider "virtualbox" do |vb|
# Display the VirtualBox GUI when booting the machine
vb.gui = false
# Customize the amount of memory on the VM:
vb.memory = "2048"
# vb.customize ["modifyvm", :id, "--natdnshostresolver1", "on"]
end
end