-
Notifications
You must be signed in to change notification settings - Fork 13
/
Vagrantfile
133 lines (110 loc) · 4 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
# -*- mode: ruby -*-
# vi: set ft=ruby :
# Common for all rhel-like distros
$bootstrap_rhel_common = <<SCRIPT
set -euxo pipefail
dnf install -y \
rust \
cargo \
clang \
llvm \
rustfmt \
elfutils-libelf-devel \
zlib-devel \
libpcap-devel \
git \
python3-pip \
python3-devel \
socat \
nftables \
make \
jq
python3 -m pip install pytest pyroute2
SCRIPT
def get_box(url, pattern)
require 'open-uri'
require 'nokogiri'
doc = Nokogiri::HTML(URI.open(url))
box = doc.css('a').map { |link| link['href'] }.select { |alink| pattern.match?(alink) }.last
url + box
end
Vagrant.configure("2") do |config|
config.vm.box_check_update = false
config.vm.define "x86_64-f40" do |fedora|
fedora.vm.box = "fedora-40-cloud"
fedora.vm.box_url = get_box("https://dl.fedoraproject.org/pub/fedora/linux/releases/40/Cloud/x86_64/images/", /.*vagrant\.libvirt\.box$/)
fedora.vm.provision "common", type: "shell", inline: $bootstrap_rhel_common
fedora.vm.provision "shell", inline: <<-SHELL
dnf install -y openvswitch
SHELL
fedora.vm.synced_folder ".", "/vagrant", type: "rsync"
end
config.vm.define "x86_64-rawhide" do |rawhide|
rawhide.vm.box = "fedora-rawhide-cloud"
rawhide.vm.box_url = get_box("https://dl.fedoraproject.org/pub/fedora/linux/development/rawhide/Cloud/x86_64/images/", /.*vagrant\.libvirt\.box$/)
rawhide.vm.provision "common", type: "shell", inline: $bootstrap_rhel_common
rawhide.vm.provision "shell", inline: <<-SHELL
dnf install -y openvswitch
SHELL
rawhide.vm.synced_folder ".", "/vagrant", type: "rsync"
end
config.vm.define "x86_64-c8s" do |centos|
centos.vm.box = "centos-8-stream"
centos.vm.box_url = get_box("https://cloud.centos.org/centos/8-stream/x86_64/images/", /.*latest\.x86_64\.vagrant-libvirt\.box$/)
# CentOS mirror URL changed but the c8s image is no longer being built. We
# have to fix them manually in order to install packages later.
centos.vm.provision "repos-fixup", type: "shell", inline: <<-SHELL
sed -i s/mirror.centos.org/vault.centos.org/g /etc/yum.repos.d/*.repo
sed -i s/^#.*baseurl=http/baseurl=http/g /etc/yum.repos.d/*.repo
sed -i s/^mirrorlist=http/#mirrorlist=http/g /etc/yum.repos.d/*.repo
SHELL
centos.vm.provision "shell", inline: <<-SHELL
dnf config-manager --set-enabled powertools
SHELL
centos.vm.provision "common", type: "shell", inline: $bootstrap_rhel_common
centos.vm.provision "shell", inline: <<-SHELL
dnf install -y centos-release-nfv-openvswitch
dnf install -y openvswitch3.1
SHELL
centos.vm.synced_folder ".", "/vagrant", type: "rsync"
end
config.vm.define "x86_64-c9s" do |centos|
centos.vm.box = "centos-9-stream"
centos.vm.box_url = get_box("https://cloud.centos.org/centos/9-stream/x86_64/images/", /.*latest\.x86_64\.vagrant-libvirt\.box$/)
centos.vm.provision "common", type: "shell", inline: $bootstrap_rhel_common
centos.vm.provision "shell", inline: <<-SHELL
dnf install -y centos-release-nfv-openvswitch
dnf install -y openvswitch3.1
SHELL
centos.vm.synced_folder ".", "/vagrant", type: "rsync"
end
config.vm.define "x86_64-jammy" do |jammy|
jammy.vm.box = "generic/ubuntu2204"
jammy.vm.provision "shell", inline: <<-SHELL
set -euxo pipefail
apt-get update -y && apt-get install -y \
clang \
curl \
llvm \
libelf-dev \
zlib1g-dev \
libpcap-dev \
git \
pkg-config \
python3-pip \
python3-dev \
openvswitch-switch \
socat \
nftables \
make \
jq
su vagrant -c "curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -qy"
python3 -m pip install pytest pyroute2
SHELL
jammy.vm.synced_folder ".", "/vagrant", type: "rsync"
end
config.vm.provider "libvirt" do |libvirt|
libvirt.cpus = 4
libvirt.memory = 4096
end
end