forked from hashicorp/puppet-bootstrap
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Vagrantfile
110 lines (95 loc) · 3.67 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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
# -*- mode: ruby -*-
# vi: set ft=ruby :
# PLUGINS = %w(vagrant-librarian-puppet vagrant-puppet-install vagrant-vbguest)
PLUGINS = %w().freeze
plugins_installed = false
PLUGINS.each do |plugin|
unless Vagrant.has_plugin?(plugin)
system("vagrant plugin install #{plugin}") && plugins_installed = true
end
end
raise('plugins installed. Run command again.') if plugins_installed
# 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|
# For a complete reference, please see the online documentation at
# https://docs.vagrantup.com.
# You can search for boxes at https://atlas.hashicorp.com/search.
config.vm.hostname = 'bootstrap'
# config.vbguest.auto_update = false
config.vm.synced_folder '.', '/vagrant', disabled: true
# Create a private network, which allows host-only access to the machine
# using a specific IP.
# config.vm.network 'private_network', :type => 'dhcp'
# Create a public network, which generally matched to bridged network.
# Bridged networks make the machine appear as another physical device on
# your network.
# config.vm.network 'public_network'
config.vm.define 'ubuntu-14.04', :primary => true do |ubuntu|
ubuntu.vm.box = 'puppetlabs/ubuntu-14.04-64-nocm'
provider_settings(ubuntu, 'ubuntu-14.04')
install_puppet(ubuntu)
end
config.vm.define 'ubuntu-16.04', :autostart => false do |ubuntu|
ubuntu.vm.box = 'puppetlabs/ubuntu-16.04-64-nocm'
provider_settings(ubuntu, 'ubuntu-16.04')
install_puppet(ubuntu)
end
config.vm.define 'centos-5.11', :autostart => false do |centos|
centos.vm.box = 'puppetlabs/centos-5.11-64-nocm'
provider_settings(centos, 'centos-5.11')
install_puppet(centos)
end
config.vm.define 'centos-6.6', :autostart => false do |centos|
centos.vm.box = 'puppetlabs/centos-6.6-64-nocm'
provider_settings(centos, 'centos-6.6')
install_puppet(centos)
end
config.vm.define 'centos-7.2', :autostart => false do |centos|
centos.vm.box = 'puppetlabs/centos-7.2-64-nocm'
provider_settings(centos, 'centos-7.2')
install_puppet(centos)
end
config.vm.define 'osx', :autostart => false do |osx|
osx.vm.box = 'jhcook/osx-elcapitan-10.11'
provider_settings(osx, 'osx-10.11', true)
install_puppet(osx)
end
config.vm.define 'windows', :autostart => false do |windows|
windows.vm.box = 'StefanScherer/windows_2019'
provider_settings(windows, 'win-2019-standard')
install_puppet(windows, 'windows')
end
# Extract common settings, whilst allowing some differences
def provider_settings(os, name, gui = false)
# Provider-specific configuration for VirtualBox:
os.vm.provider 'virtualbox' do |vb|
vb.name = "bootstrap-#{name}"
vb.gui = gui
vb.memory = 2048
vb.cpus = 2
vb.customize ['modifyvm', :id, '--ioapic', 'on']
end
# Add other supported providers...
end
def install_puppet(os, kernel = 'unix')
# Provision with Shell to install puppet and prep for puppet dependencies
case kernel.to_s
when 'unix'
os.vm.provision 'shell', :inline => <<-SHELL
curl -sSL https://git.io/vLD6L | sudo bash -s '' locdev 5
SHELL
when 'windows'
os.vm.provision 'shell', :inline => <<-SHELL
$env:PuppetCollection = '5'
$env:PuppetVersion = '5.5.21'
$env:PuppetEnvironment = 'locdev'
iex ((New-Object System.Net.WebClient).DownloadString('https://git.io/vanax'))
SHELL
else
raise("Don't know how to install puppet on #{kernel}")
end
end
end