forked from rancher/quickstart
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Vagrantfile
60 lines (53 loc) · 2.4 KB
/
Vagrantfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# -*- mode: ruby -*-
# vi: set ft=ruby :
require_relative 'vagrant_rancheros_guest_plugin.rb'
require 'ipaddr'
require 'yaml'
if File.exists?(File.join(File.dirname(__FILE__), "local_config.yaml")) then
puts "Using local configuration file"
x = YAML.load_file(File.join(File.dirname(__FILE__), "local_config.yaml"))
else
x = YAML.load_file(File.join(File.dirname(__FILE__), 'config.yaml'))
end
puts "Config: #{x.inspect}\n\n"
$private_nic_type = x.fetch('net').fetch('private_nic_type')
Vagrant.configure(2) do |config|
if Vagrant.has_plugin?("vagrant-proxyconf")
config.proxy.enabled = { docker: false }
end
config.vm.define "server-01" do |server|
c = x.fetch('server')
server.vm.box= "chrisurwin/RancherOS"
server.vm.box_version = x.fetch('ROS_version')
server.vm.guest = :linux
server.vm.provider :virtualbox do |v|
v.customize ["modifyvm", :id, "--natdnshostresolver1", "on"]
v.cpus = c.fetch('cpus')
v.linked_clone = true if Gem::Version.new(Vagrant::VERSION) >= Gem::Version.new('1.8.0') and x.fetch('linked_clones')
v.memory = c.fetch('memory')
v.name = "server-01"
end
server.vm.network x.fetch('net').fetch('network_type'), ip: x.fetch('ip').fetch('server') , nic_type: $private_nic_type
server.vm.hostname = "server-01"
server.vm.provision "shell", path: "scripts/configure_rancher_server.sh", args: [x.fetch('admin_password'), x.fetch('rancher_version'), x.fetch('k8s_version')]
end
node_ip = IPAddr.new(x.fetch('ip').fetch('node'))
(1..x.fetch('node').fetch('count')).each do |i|
c = x.fetch('node')
hostname = "node-%02d" % i
config.vm.define hostname do |node|
node.vm.box = "chrisurwin/RancherOS"
node.vm.box_version = x.fetch('ROS_version')
node.vm.guest = :linux
node.vm.provider "virtualbox" do |v|
v.cpus = c.fetch('cpus')
v.linked_clone = true if Gem::Version.new(Vagrant::VERSION) >= Gem::Version.new('1.8.0') and x.fetch('linked_clones')
v.memory = c.fetch('memory')
v.name = hostname
end
node.vm.network x.fetch('net').fetch('network_type'), ip: IPAddr.new(node_ip.to_i + i - 1, Socket::AF_INET).to_s, nic_type: $private_nic_type
node.vm.hostname = hostname
node.vm.provision "shell", path: "scripts/configure_rancher_node.sh", args: [x.fetch('ip').fetch('server'), x.fetch('admin_password')]
end
end
end