-
Notifications
You must be signed in to change notification settings - Fork 0
/
Vagrantfile
71 lines (56 loc) · 1.69 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
# -*- mode: ruby -*-
# vi: set ft=ruby :
###############
# Variables #
###############
CPUS = 4
RAM = 4096
BOX = "bento/ubuntu-22.04"
BOX_LIBVIRT = "generic/ubuntu2204"
#######################
# Provision Scripts #
#######################
$bootstrap= <<-SCRIPT
DEBIAN_FRONTEND=noninteractive apt-get update
DEBIAN_FRONTEND=noninteractive apt-get upgrade -y
APT_PKGS=(
ansible
python3-pip
)
DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends "${APT_PKGS[@]}"
SCRIPT
$setup_libvirt_vm_always= <<-SCRIPT
# Configure the SSH server to allow X11 forwarding with sudo
cp /vagrant/comnetsemu/util/sshd_config /etc/ssh/sshd_config
systemctl restart sshd.service
SCRIPT
#################
# Main Config #
#################
Vagrant.configure("2") do |config|
config.vm.define "playground" do |playground|
playground.vm.box = BOX
playground.vm.hostname = "playground"
playground.vm.provider "virtualbox" do |vb|
vb.memory = RAM
vb.cpus = CPUS
end
playground.vm.provider "libvirt" do |libvirt, override|
override.vm.box = BOX_LIBVIRT
override.vm.synced_folder ".", "/vagrant", type: "nfs", nfs_version: 4
libvirt.driver = "kvm"
libvirt.cpus = CPUS
libvirt.memory = RAM
end
playground.vm.provision :shell, inline: $bootstrap
playground.vm.provision "ansible_local" do |ansible|
ansible.playbook = "./ansible/bootstrap.yml"
ansible.install = false
end
playground.vm.provider "libvirt" do |libvirt, override|
override.vm.provision :shell, inline: $setup_libvirt_vm_always, privileged: true, run: "always"
end
playground.ssh.forward_agent = true
playground.ssh.forward_x11 = true
end
end