-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* This allows development on non-Linux environments. * This allows you to put heckler on it's own VLAN. * VMs can be convenient.
- Loading branch information
1 parent
1ef22b3
commit 826d60d
Showing
2 changed files
with
115 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
# -*- mode: ruby -*- | ||
# vi: set ft=ruby : | ||
|
||
LIBVIRT_HOST_IP = ENV["LIBVIRT_HOST_IP"] || "192.168.56.1" | ||
HECKLER_IP = ENV["HECKLER_IP"] || "192.168.56.4" | ||
BRIDGE_IF = ENV["BRIDGE_IF"] || false | ||
|
||
Vagrant.configure("2") do |config| | ||
config.vm.provider :libvirt do |libvirt| | ||
libvirt.qemu_use_session = false | ||
end | ||
|
||
config.vm.define "heckler" do |heckler| | ||
heckler.vm.box = "generic/ubuntu2004" | ||
heckler.vm.synced_folder "./", "/heckler/" | ||
|
||
if BRIDGE_IF | ||
heckler.vm.network "public_network", ip: HECKLER_IP, | ||
bridge: BRIDGE_IF, | ||
libvirt__network_name: "heckler_network", | ||
libvirt__host_ip: LIBVIRT_HOST_IP, | ||
libvirt__netmask: "255.255.255.0", | ||
libvirt__dhcp_enabled: false, | ||
auto_config: false | ||
else | ||
heckler.vm.network "private_network", ip: HECKLER_IP, | ||
libvirt__network_name: "heckler_network", | ||
libvirt__host_ip: LIBVIRT_HOST_IP, | ||
libvirt__netmask: "255.255.255.0", | ||
libvirt__dhcp_enabled: false, | ||
auto_config: false | ||
end | ||
|
||
heckler.vm.provider "virtualbox" do |v, override| | ||
v.memory = 2048 | ||
v.cpus = 2 | ||
override.vm.synced_folder "./", "/heckler/" | ||
end | ||
|
||
heckler.vm.provider "libvirt" do |l, override| | ||
l.memory = 2048 | ||
l.cpus = 2 | ||
override.vm.synced_folder "./", "/heckler/" | ||
end | ||
|
||
heckler.vm.provision :shell, path: "setup.sh", args: [HECKLER_IP] | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
#!/usr/bin/env bash | ||
|
||
install_docker() { | ||
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - | ||
add-apt-repository "deb https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | ||
update_apt | ||
apt-get install --no-install-recommends containerd.io docker-ce docker-ce-cli | ||
gpasswd -a vagrant docker | ||
} | ||
|
||
install_docker_compose() { | ||
apt-get install --no-install-recommends python3-pip | ||
pip install docker-compose | ||
} | ||
|
||
apt-get() { | ||
DEBIAN_FRONTEND=noninteractive command apt-get \ | ||
--allow-change-held-packages \ | ||
--allow-downgrades \ | ||
--allow-remove-essential \ | ||
--allow-unauthenticated \ | ||
--option Dpkg::Options::=--force-confdef \ | ||
--option Dpkg::Options::=--force-confold \ | ||
--yes \ | ||
"$@" | ||
} | ||
|
||
update_apt() { | ||
apt-get update | ||
} | ||
|
||
setup_layer2_network() { | ||
local host_ip=$1 | ||
ip addr show dev eth1 | grep -q "$host_ip" && return 0 | ||
ip addr add "$host_ip/24" dev eth1 | ||
ip link set dev eth1 up | ||
} | ||
|
||
tweak_bash_interactive_settings() { | ||
readarray -t aliases <<-EOF | ||
dc=docker-compose | ||
EOF | ||
for alias in "${aliases[@]}"; do | ||
grep -q "$alias" ~vagrant/.bash_aliases || echo "alias $alias" >>~vagrant/.bash_aliases | ||
done | ||
} | ||
|
||
main() { | ||
local host_ip=$1 | ||
|
||
update_apt | ||
install_docker | ||
install_docker_compose | ||
|
||
setup_layer2_network "$host_ip" | ||
|
||
docker-compose -f /heckler/docker-compose/docker-compose.yml up -d | ||
|
||
tweak_bash_interactive_settings | ||
} | ||
|
||
if [[ ${BASH_SOURCE[0]} == "$0" ]]; then | ||
set -euxo pipefail | ||
|
||
main "$@" | ||
echo "all done!" | ||
fi |