forked from franlr/ocs
-
Notifications
You must be signed in to change notification settings - Fork 10
/
Vagrantfile
101 lines (82 loc) · 3.27 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
# -*- mode: ruby -*-
# vi: set ft=ruby :
# Requirements:
#
# * Virtualbox
#
# * Vagrant
#
# * Vagrant plugins:
# + vagrant-proxyconf (if needed)
# + vagrant-cachier
# + vagrant-vbguest
VAGRANTFILE_API_VERSION = "2"
HOSTNAME = "testvm"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
if Vagrant.has_plugin?("vagrant-cachier")
config.cache.synced_folder_opts = {
owner: "_apt"
}
config.cache.scope = :box
end
config.vm.define HOSTNAME do |srv|
srv.vm.box = "ubuntu/focal64"
srv.vm.network "private_network", ip: "192.168.33.11"
srv.vm.boot_timeout = 3600
srv.vm.box_check_update = false
srv.ssh.forward_agent = true
srv.ssh.forward_x11 = true
srv.vm.hostname = HOSTNAME
srv.vm.provider :virtualbox do |vb|
vb.gui = false
vb.cpus = 2
vb.memory = "1536"
end
end
config.vm.provision "fix-no-tty", type: "shell" do |s|
s.privileged = false
s.inline = "sudo sed -i '/tty/!s/mesg n/tty -s \\&\\& mesg n/' /root/.profile"
end
config.vm.provision "operating-system-update", type: "shell" do |s| # http://foo-o-rama.com/vagrant--stdin-is-not-a-tty--fix.html
s.privileged = false
s.inline = <<-SHELL
export DEBIAN_FRONTEND=noninteractive
export APT_LISTCHANGES_FRONTEND=none
export APT_OPTIONS=' -y --allow-downgrades --allow-remove-essential --allow-change-held-packages -o Dpkg::Options::=--force-confdef -o Dpkg::Options::=--force-confold '
# https://serverfault.com/a/717770
sudo ex +"%s@DPkg@//DPkg" -cwq /etc/apt/apt.conf.d/70debconf
sudo dpkg-reconfigure debconf -f noninteractive -p critical
sudo apt-get update -y -qq
sudo apt-get upgrade ${APT_OPTIONS}
sudo apt-get full-upgrade ${APT_OPTIONS}
sudo apt-get autoremove -y
SHELL
end
proxy_host_port = ENV['all_proxy'] || ENV['http_proxy'] || ""
proxy_host_port = if proxy_host_port.empty? then "" else proxy_host_port.scan(/\/\/([0-9\.]*):/)[0][0]+':'+proxy_host_port.scan(/:([0-9]*)$/)[0][0] end
config.vm.provision "pip-ansible-install", type: "shell" do |s|
s.privileged = false
s.inline = <<-SHELL
export DEBIAN_FRONTEND=noninteractive
export APT_LISTCHANGES_FRONTEND=none
export APT_OPTIONS=' -y --allow-downgrades --allow-remove-essential --allow-change-held-packages -o Dpkg::Options::=--force-confdef -o Dpkg::Options::=--force-confold '
sudo apt-get install python3-pip ${APT_OPTIONS}
sudo -H python3 -m pip install pip setuptools wheel
sudo -H python3 -m pip install ansible
SHELL
end
config.vm.provision "ansible-provision", type: :ansible, run: "never" do |ansible|
ansible.playbook = "./tests/test.yml"
ansible.config_file = "./vagrant-inventory/ansible.cfg"
ansible.inventory_path = "./vagrant-inventory/"
ansible.verbose= "-v"
ansible.become = true
ansible.extra_vars = {
all_proxy: ENV['all_proxy'] || ENV['http_proxy'] || "",
http_proxy: ENV['http_proxy'] || "",
https_proxy: ENV['https_proxy'] || "",
ftp_proxy: ENV['ftp_proxy'] || "",
no_proxy: ENV['no_proxy'] || "",
}
end
end