forked from jenkins-infra/jenkins-infra
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathVagrantfile
57 lines (51 loc) · 2.19 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
Vagrant.configure("2") do |config|
## Docker provider
config.vm.provider "docker" do |d|
d.build_dir = "./vagrant-docker/"
d.create_args = [
"--privileged=true",
"--cgroupns=host",
]
d.volumes = [
"/sys/fs/cgroup:/sys/fs/cgroup:rw",
"/var/lib/docker",
]
d.has_ssh = true
end
# Add a secondary NIC ("private" network simulation for roles such as openvpn)
config.vm.network "private_network", ip: "192.168.0.10", netmask: 24, docker_network__internal: true, docker_network__gateway: "192.168.0.1"
config.vm.network "forwarded_port", guest: 80, host: 80
config.vm.network "forwarded_port", guest: 443, host: 443
config.vm.network "forwarded_port", guest: 8080, host: 8080
role_dir = './dist/role/manifests/'
Dir["#{role_dir}**/*.pp"].each do |role|
next if File.directory? role
# Turn `dist/role/manifests/spinach.pp` into `spinach`
veggie = role.gsub(role_dir, '').gsub('/', '::').gsub('.pp', '')
specfile = veggie.gsub('::', '_')
# If there are no serverspec files, we needn't provision a machine!
if Dir["./spec/server/#{specfile}/*.rb"].empty?
STDERR.write(">> no serverspec defined for #{veggie}\n")
next
end
config.vm.define(veggie) do |node|
# https://www.vagrantup.com/docs/provisioning/puppet_apply
node.vm.provision "puppet" do |puppet|
puppet.binary_path = "/opt/puppetlabs/bin"
puppet.module_path = ["dist","modules"]
puppet.environment = "vagrant"
puppet.facter = {
"vagrant" => "1",
"veggie" => veggie,
"clientcert" => veggie,
"hiera_role" => veggie,
}
puppet.working_directory = "/vagrant"
puppet.manifests_path = "manifests"
puppet.manifest_file = "site.pp"
puppet.options = "--hiera_config=/vagrant/vagrant-docker/hiera.yaml --execute 'require profile::vagrant\n include role::#{veggie}'"
end
end
end
end
# vim: ft=ruby