forked from projectatomic/adb-atomic-developer-bundle
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathVagrantfile
81 lines (67 loc) · 2.87 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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# -*- mode: ruby -*-
# vi: set ft=ruby :
BOX_NAME = 'projectatomic/adb'
REQUIRED_PLUGINS = %w(vagrant-service-manager vagrant-sshfs)
errors = []
def message(name)
"#{name} plugin is not installed, run `vagrant plugin install #{name}` to install it."
end
# Validate and collect error message if plugin is not installed
REQUIRED_PLUGINS.each { |plugin| errors << message(plugin) unless Vagrant.has_plugin?(plugin) }
unless errors.empty?
msg = errors.size > 1 ? "Errors: \n* #{errors.join("\n* ")}" : "Error: #{errors.first}"
fail Vagrant::Errors::VagrantError.new, msg
end
# Vagrantfile for single node k8s setup
Vagrant.configure(2) do |config|
# Use environment variable BOX or default 'projectatomic/adb'
config.vm.box = (ENV.key?('BOX') ? (ENV['BOX'].empty? ? BOX_NAME : ENV['BOX']) : BOX_NAME)
config.vm.provider "libvirt" do |libvirt, override|
libvirt.driver = "kvm"
libvirt.memory = 1024
libvirt.cpus = 2
libvirt.suspend_mode = "managedsave"
end
config.vm.provider "virtualbox" do |vbox, override|
vbox.memory = 1024
vbox.cpus = 2
# Enable use of more than one virtual CPU in a virtual machine.
vbox.customize ["modifyvm", :id, "--ioapic", "on"]
end
# Setup a DHCP based private network
config.vm.network "private_network", type: "dhcp"
config.vm.provider "openstack" do |os|
# Specify OpenStack authentication information
os.openstack_auth_url = ENV['OS_AUTH_URL']
os.tenant_name = ENV['OS_TENANT_NAME']
os.username = ENV['OS_USERNAME']
os.password = ENV['OS_PASSWORD']
# Specify instance information
os.server_name = ENV['OS_INSTANCE']
os.flavor = ENV['OS_FLAVOR']
os.image = ENV['OS_IMAGE']
os.floating_ip_pool = ENV['OS_FLOATING_IP_POOL']
os.security_groups = ['default', ENV['OS_SECURITY_GROUP']]
os.keypair_name = ENV['OS_KEYPAIR_NAME']
config.ssh.private_key_path = ENV['OS_PRIVATE_KEYPATH']
config.ssh.username = 'vagrant'
end
# Proxy Information from environment
PROXY = (ENV['PROXY'] || '')
PROXY_USER = (ENV['PROXY_USER'] || '')
PROXY_PASSWORD = (ENV['PROXY_PASSWORD'] || '')
config.vm.synced_folder '.', '/vagrant', disabled: true
if Vagrant::Util::Platform.windows?
target_path = ENV['USERPROFILE'].gsub(/\\/,'/').gsub(/[[:alpha:]]{1}:/){|s|'/' + s.downcase.sub(':', '')}
config.vm.synced_folder ENV['USERPROFILE'], target_path, type: 'sshfs', sshfs_opts_append: '-o umask=000 -o uid=1000 -o gid=1000'
else
config.vm.synced_folder ENV['HOME'], ENV['HOME'], type: 'sshfs', sshfs_opts_append: '-o umask=000 -o uid=1000 -o gid=1000'
end
config.vm.provision "shell", inline: <<-SHELL
sudo setsebool -P virt_sandbox_use_fusefs 1
SHELL
# Explicitly enable and start kubernetes
config.vm.provision "shell", run: "always", inline: <<-SHELL
PROXY=#{PROXY} PROXY_USER=#{PROXY_USER} PROXY_PASSWORD=#{PROXY_PASSWORD} /usr/bin/sccli kubernetes
SHELL
end