-
Notifications
You must be signed in to change notification settings - Fork 4
/
Vagrantfile
186 lines (171 loc) · 7.96 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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
# -*- mode: ruby -*-
# vi: set ft=ruby :
# Workaround https://github.com/mitchellh/vagrant-aws/issues/566
class Hash
def slice(*keep_keys)
h = {}
keep_keys.each { |key| h[key] = fetch(key) if has_key?(key) }
h
end unless Hash.method_defined?(:slice)
def except(*less_keys)
slice(*keys - less_keys)
end unless Hash.method_defined?(:except)
end
Vagrant.configure("2") do |config|
config.vm.define "packager" do |box|
box.vm.box = "ubuntu/bionic64"
box.vm.box_version = "20200402.0.0"
box.vm.hostname = "packager.local"
box.vm.network "private_network", ip: "192.168.57.200"
box.vm.synced_folder ".", "/vagrant", type: "rsync", disabled: true
box.vm.synced_folder ".", "/home/ubuntu/puppetmaster-installer", type: "virtualbox"
box.vm.provision "shell", path: "vagrant/prepare_packager.sh"
box.vm.provider "virtualbox" do |vb|
vb.gui = false
vb.memory = 1024
end
end
config.vm.define "puppetserver-buster" do |box|
box.vm.box = "debian/contrib-buster64"
box.vm.box_version = "10.3.0"
box.vm.hostname = "puppet.local"
box.vm.network "private_network", ip: "192.168.57.202"
# Disable default rsync shared folder. Some boxes like debian/stretch64
# require this or the vboxsf mount will fail.
box.vm.synced_folder ".", "/vagrant", type: "rsync", disabled: true
box.vm.synced_folder ".", "/usr/share/puppetmaster-installer", type: "virtualbox"
box.vm.provision "shell" do |s|
s.path = "vagrant/prepare.sh"
s.args = ["-b", "/usr/share/puppetmaster-installer", "-m"]
s.env = {"RUN_INSTALLER" => ENV['RUN_INSTALLER'],
"SCENARIO" => ENV['SCENARIO'] }
end
box.vm.provision "shell", path: "vagrant/install_keys.sh"
box.vm.provider "virtualbox" do |vb|
vb.gui = false
vb.memory = 4096
end
end
config.vm.define "puppetserver-centos7" do |box|
box.vm.box = "centos/7"
box.vm.box_version = "1905.1"
box.vm.hostname = "puppet.local"
box.vm.network "private_network", ip: "192.168.57.203"
box.vm.synced_folder ".", "/vagrant", type: "rsync", disabled: true
box.vm.synced_folder ".", "/usr/share/puppetmaster-installer", type: "virtualbox"
box.vm.provision "shell" do |s|
s.path = "vagrant/prepare.sh"
s.args = ["-b", "/usr/share/puppetmaster-installer", "-m"]
s.env = {"RUN_INSTALLER" => ENV['RUN_INSTALLER'],
"SCENARIO" => ENV['SCENARIO'] }
end
box.vm.provision "shell", path: "vagrant/install_keys.sh"
box.vm.provider "virtualbox" do |vb|
vb.gui = false
vb.memory = 5120
end
end
config.vm.define "puppetserver-proxy" do |box|
box.vm.box = "centos/7"
box.vm.box_version = "2020.01"
box.vm.hostname = "proxy2.local"
box.vm.network "private_network", ip: "192.168.57.205"
box.vm.synced_folder ".", "/vagrant", type: "rsync", disabled: true
box.vm.synced_folder ".", "/home/puppetmaster", type: "virtualbox"
box.vm.provision "shell" do |s|
s.path = "vagrant/prepare.sh"
s.args = ["-b", "/home/puppetmaster", "-m"]
end
box.vm.provider "virtualbox" do |vb|
vb.gui = false
vb.memory = 2048
end
end
config.vm.define "puppetserver-bionic" do |box|
box.vm.box = "ubuntu/bionic64"
box.vm.box_version = "20200402.0.0"
box.vm.hostname = "puppet.local"
box.vm.network "private_network", ip: "192.168.57.206"
box.vm.synced_folder ".", "/vagrant", type: "rsync", disabled: true
box.vm.synced_folder ".", "/usr/share/puppetmaster-installer", type: "virtualbox"
box.vm.provision "shell" do |s|
s.path = "vagrant/prepare.sh"
s.args = ["-b", "/usr/share/puppetmaster-installer", "-m"]
s.env = {"RUN_INSTALLER" => ENV['RUN_INSTALLER'],
"SCENARIO" => ENV['SCENARIO'] }
end
box.vm.provision "shell", path: "vagrant/install_keys.sh"
box.vm.provider "virtualbox" do |vb|
vb.gui = false
vb.memory = 4096
end
end
config.vm.define "puppetserver-focal" do |box|
box.vm.box = "ubuntu/focal64"
box.vm.box_version = "20230119.0.0"
box.vm.hostname = "puppet.local"
box.vm.network "private_network", ip: "192.168.57.207"
box.vm.synced_folder ".", "/vagrant", type: "rsync", disabled: true
box.vm.synced_folder ".", "/usr/share/puppetmaster-installer", type: "virtualbox"
box.vm.provision "shell" do |s|
s.path = "vagrant/prepare.sh"
s.args = ["-b", "/usr/share/puppetmaster-installer", "-m"]
s.env = {"RUN_INSTALLER" => ENV['RUN_INSTALLER'],
"SCENARIO" => ENV['SCENARIO'] }
end
box.vm.provision "shell", path: "vagrant/install_keys.sh"
box.vm.provider "virtualbox" do |vb|
vb.gui = false
vb.memory = 4096
end
end
config.vm.define "puppetserver-aws" do |box|
# Create an empty file to keep vagrant-aws happy
dummy_keypair_path = "/tmp/.puppetserver-aws-dummy-keypair"
dummy_keypair = File.new(dummy_keypair_path, "w")
dummy_keypair.close
# Set dummy values to allow this Vagrantfile to work even if these are unset
aws_ami = ENV['AWS_AMI'] ? ENV['AWS_AMI'] : "invalid"
aws_keypair_name = ENV['AWS_KEYPAIR_NAME'] ? ENV['AWS_KEYPAIR_NAME'] : "invalid"
aws_region = ENV['AWS_DEFAULT_REGION'] ? ENV['AWS_DEFAULT_REGION'] : "us-east-1"
ssh_private_key_path = ENV['SSH_PRIVATE_KEY_PATH'] ? ENV['SSH_PRIVATE_KEY_PATH'] : dummy_keypair_path
box.vm.box = "dummy"
box.vm.hostname = "puppet.local"
box.vm.provider :aws do |aws, override|
aws.ami = aws_ami
aws.keypair_name = aws_keypair_name
aws.region = aws_region
aws.tags = { 'Name' => 'puppetmaster-bionic-aws' }
override.ssh.username = "ubuntu"
override.ssh.private_key_path = ssh_private_key_path
end
# Copy files required by installer tests
if ENV['RUN_INSTALLER']
abort "ERROR: environment variable ANSWER_FILE must be set! Point it to the basename of the answer file on the Vagrant host." unless ENV['ANSWER_FILE']
abort "ERROR: environment variable SCENARIO must be set! It must be a valid scenario name." unless ENV['SCENARIO']
installer_dir="/usr/share/puppetmaster-installer"
scenarios_dir="#{installer_dir}/config/installer-scenarios.d"
box.vm.provision "file", source: File.join(File.dirname(__FILE__), "vagrant/test/#{ENV['ANSWER_FILE']}"), destination: "/tmp/#{ENV['ANSWER_FILE']}"
box.vm.provision "shell", inline: "rm -f #{scenarios_dir}/last_scenario.yaml"
box.vm.provision "shell", inline: "cp /tmp/#{ENV['ANSWER_FILE']} #{scenarios_dir}/#{ENV['SCENARIO']}-answers.yaml"
box.vm.provision "shell", inline: "ln -s #{scenarios_dir}/#{ENV['SCENARIO']}.yaml #{scenarios_dir}/last_scenario.yaml"
# Copy r10k key over for setups that need it
if ENV['R10K_KEY']
box.vm.provision "file", source: ENV['R10K_KEY'], destination: "/tmp/r10k_key"
box.vm.provision "shell", inline: "mkdir #{installer_dir}/keys"
box.vm.provision "shell", inline: "mv /tmp/r10k_key #{installer_dir}/keys"
end
# We need to wait until systemd apt timers have ran or running the installer will fail mysteriously
#
# <https://unix.stackexchange.com/questions/315502/how-to-disable-apt-daily-service-on-ubuntu-cloud-vm-image>
# <https://github.com/Puppet-Finland/scripts/blob/master/bootstrap/linux/install-puppet.sh>
#
box.vm.provision "shell", path: File.join(File.dirname(__FILE__), "vagrant/wait_for_apt.sh")
box.vm.provision "shell", inline: "/usr/bin/hostnamectl set-hostname puppet.vagrant.example.lan"
box.vm.provision "shell", inline: "#{installer_dir}/bin/puppetmaster-installer --scenario #{ENV['SCENARIO']} --dont-save-answers "
box.vm.provision "shell", inline: "/opt/puppetlabs/puppet/bin/r10k deploy environment production -vp" if ENV['RUN_R10K'] == 'true'
box.vm.provision "shell", path: File.join(File.dirname(__FILE__), "vagrant/wait_for_puppet_agent.sh")
box.vm.provision "shell", inline: "/opt/puppetlabs/bin/puppet agent -t"
end
end
end