Last active
November 1, 2017 18:22
-
-
Save yogeek/a260c6f6a58c49bafb367e2a04fd4c00 to your computer and use it in GitHub Desktop.
Vagrantfile examples
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 : | |
disk = './secondDisk.vdi' | |
Vagrant.configure(2) do |config| | |
#config.vm.box = "ubuntu/xenial64" | |
config.vm.box = "VM-CO72-BASE" | |
# config.vm.box_check_update = false | |
config.vm.synced_folder ".", "/vagrant", disabled: true | |
#if Vagrant.has_plugin?("vagrant-proxyconf") | |
# config.proxy.http = "http://10.10.10.10:8080" | |
# config.proxy.https = "http://10.10.10.10:8080" | |
# config.proxy.no_proxy = "localhost,127.0.0.1" | |
#end | |
config.vm.provider "virtualbox" do |v| | |
v.memory = 256 | |
unless File.exist?(disk) | |
v.customize ['createhd', '--filename', disk, '--variant', 'Fixed', '--size', 2 * 1024] | |
end | |
v.customize ['storageattach', :id, '--storagectl', 'SATA Controller', '--port', 1, '--device', 0, '--type', 'hdd', '--medium', disk] | |
end | |
config.vm.define "manager-1" do |node| | |
node.vm.hostname = "manager-1" | |
node.vm.network "private_network", ip: "192.168.33.1#{i}" | |
node.vm.network "forwarded_port", guest: 80, host: 8080 | |
end | |
end | |
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 : | |
disk = './secondDisk.vdi' | |
Vagrant.configure(2) do |config| | |
#config.vm.box = "ubuntu/xenial64" | |
config.vm.box = "VM-CO72-BASE" | |
# config.vm.box_check_update = false | |
config.vm.synced_folder ".", "/vagrant", disabled: true | |
#if Vagrant.has_plugin?("vagrant-proxyconf") | |
# config.proxy.http = "http://10.10.10.10:8080" | |
# config.proxy.https = "http://10.10.10.10:8080" | |
# config.proxy.no_proxy = "localhost,127.0.0.1" | |
#end | |
config.vm.provider "virtualbox" do |v| | |
v.memory = 256 | |
unless File.exist?(disk) | |
v.customize ['createhd', '--filename', disk, '--variant', 'Fixed', '--size', 2 * 1024] | |
end | |
v.customize ['storageattach', :id, '--storagectl', 'SATA Controller', '--port', 1, '--device', 0, '--type', 'hdd', '--medium', disk] | |
end | |
config.vm.provision "shell", inline: <<-SHELL | |
yum update | |
yum install -y python | |
#curl "https://bootstrap.pypa.io/get-pip.py" -o "get-pip.py" && python get-pip.py | |
#pip install docker-py | |
SHELL | |
(1..3).each do |i| | |
if [1].include?(i) | |
config.vm.define "manager-#{i}" do |node| | |
node.vm.hostname = "manager-#{i}" | |
node.vm.network "private_network", ip: "192.168.33.1#{i}" | |
node.vm.network "forwarded_port", guest: 80, host: 8080 | |
end | |
else | |
config.vm.define "worker-#{i}" do |node| | |
node.vm.hostname = "worker-#{i}" | |
node.vm.network "private_network", ip: "192.168.33.1#{i}" | |
# node.vm.network "forwarded_port", guest: 80, host: 8080 | |
# hack to only run once at the end | |
#if i == 3 | |
# node.vm.provision "ansible" do |ansible| | |
# ansible.playbook = "playbook.yml" | |
# ansible.limit = "all" | |
# ansible.extra_vars = { | |
# swarm_iface: "eth1" | |
# } | |
# ansible.groups = { | |
# "docker_swarm_manager" => ["manager-[1]"], | |
# "docker_swarm_worker" => ["worker-[2:3]"], | |
# "docker_engine" => ["manager-1","worker-2","worker-3"] | |
# } | |
# ansible.raw_arguments = [ | |
# "-M ./library" | |
# ] | |
# end | |
#end | |
end | |
end | |
end | |
end |
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
# Add a second disk to system using vagrant | |
file_to_disk = './tmp/large_disk.vdi' | |
Vagrant::Config.run do |config| | |
config.vm.box = 'base' | |
config.vm.customize ['createhd', '--filename', file_to_disk, '--size', 500 * 1024] | |
config.vm.customize ['storageattach', :id, '--storagectl', 'SATA Controller', '--port', 1, '--device', 0, '--type', 'hdd', '--medium', file_to_disk] | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment