-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathVagrantfile
More file actions
65 lines (52 loc) · 1.63 KB
/
Vagrantfile
File metadata and controls
65 lines (52 loc) · 1.63 KB
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
# -*- mode: ruby -*-
# vi: set ft=ruby :
require 'getoptlong'
opts = GetoptLong.new(
[ '--env', GetoptLong::OPTIONAL_ARGUMENT ],
[ '--tags', GetoptLong::OPTIONAL_ARGUMENT ],
[ '--verbose', GetoptLong::OPTIONAL_ARGUMENT ],
[ '--ssh-port', GetoptLong::OPTIONAL_ARGUMENT ],
)
env = 'prod'
tags = 'all'
verbose = ''
ssh_port = ''
opts.ordering=(GetoptLong::REQUIRE_ORDER) ### this line avoids having errors when using Vagrant native arguments, i.e.: --debug
opts.each do |opt, arg|
case opt
when '--tags'
tags=arg
when '--verbose'
verbose=arg
when '--ssh-port'
ssh_port=arg
end
end
Vagrant.configure("2") do |config|
config.vm.box = "ubuntu/focal64"
unless ssh_port.strip.empty?
config.vm.network "forwarded_port", id: "ssh2", guest: ssh_port, host: ssh_port
config.ssh.port = ssh_port
end
config.vm.define "virtualbox" do |virtualbox|
virtualbox.vm.hostname = "test-box"
# virtualbox.vm.network :private_network, ip: "172.16.3.2"
config.vm.provider :virtualbox do |v|
v.gui = false
v.memory = 512
v.cpus = 1
v.customize ["modifyvm", :id, "--natdnshostresolver1", "on"]
v.customize ["modifyvm", :id, "--ioapic", "on"]
end
config.vm.provision "ansible", run: "always" do |ansible|
ansible.become = true
ansible.ask_become_pass = false
ansible.tags = tags
ansible.verbose = verbose
ansible.extra_vars = {
env: env
}
ansible.playbook = "playbook.yaml"
end
end
end