Skip to content

Instantly share code, notes, and snippets.

@double-p
Created April 16, 2016 07:03
Show Gist options
  • Save double-p/92d1212d867afd12f0486cd143962997 to your computer and use it in GitHub Desktop.
Save double-p/92d1212d867afd12f0486cd143962997 to your computer and use it in GitHub Desktop.
Create an OpenBSD 5.9 playground
  • adapt OpenBSD-config.json if need be
  • adapt OpenBSD-59.json for ''iso_url''
  • packer build -var-file=OpenBSD-config.json OpenBSD-59.json
  • vagrant box add obsd59 packer_vbox-obsd-59-amd64_virtualbox.box
  • Vagrantfile as provided
  • vagrant up --provision

This will create isolated networks where tenant1+2 are connected to rdomain-gw-left. Also rdomain-gw-left is connected to rdomain-gw-right and rdomain-gw-right to inetsrv via vboxnets.

{
"variables": {
"hostname": "",
"architecture": "",
"keyboard_layout": "",
"root_password": "",
"timezone": "",
"ntp_pool": ""
},
"builders": [
{
"type": "virtualbox-iso",
"name": "vbox-obsd-59-amd64",
"boot_command": [
"S<enter>",
"cat <<EOF >>install.conf<enter>",
"Choose your keyboard layout = {{user `keyboard_layout`}}<enter>",
"System hostname = {{user `hostname`}}<enter>",
"Password for root = {{user `root_password`}}<enter>",
"Start sshd(8) by default = yes<enter>",
"Do you expect to run the X Window System = no<enter>",
"Allow root ssh login = yes<enter>",
"What timezone are you in = {{user `timezone`}}<enter>",
"Location of sets = CD<enter>",
"Set name(s) = -comp*.tgz -game*.tgz -x* +bsd.mp<enter>",
"verification = yes<enter>",
"SHA256.sig. = yes<enter>",
"EOF<enter>",
"install -af install.conf && reboot<enter>"
],
"boot_wait": "15s",
"disk_size": 5120,
"guest_os_type": "OpenBSD_64",
"iso_url": "file:///Software/ISOs/install59.iso",
"iso_checksum": "685262fc665425c61a2952b2820389a2d331ac5558217080e6d564d2ce88eecb",
"iso_checksum_type": "sha256",
"ssh_username": "root",
"ssh_password": "vagrant",
"ssh_wait_timeout": "10m",
"shutdown_command": "echo '/sbin/halt -p' > shutdown.sh; sh 'shutdown.sh'",
"guest_additions_path": "disable",
"virtualbox_version_file": ".vbox_version",
"vboxmanage": [
[ "modifyvm", "{{.Name}}", "--memory", "64" ],
[ "modifyvm", "{{.Name}}", "--cpus", "1" ]
]
}
],
"provisioners": [
{
"type": "shell",
"environment_vars": [
"PKG_PATH=http://artfiles.org/openbsd/5.9/packages/amd64/"
],
"inline": "pkg_add -Iz sudo-1.8.15"
}
],
"post-processors": ["vagrant"]
}
{
"hostname": "openbsd",
"architecture": "amd64",
"keyboard_layout": "us",
"root_password": "vagrant",
"timezone": "Europe/Berlin",
"ntp_pool": "de.pool.ntp.org"
}
$routes=<<SCRIPT
route delete default
[ -z "$1" ] || route add default $1
SCRIPT
Vagrant.configure("2") do |config|
config.vm.guest = :openbsd
config.ssh.shell = "ksh -l"
config.ssh.username = "root"
config.ssh.password = "vagrant"
config.vm.box = "obsd59"
config.vm.synced_folder ".", "/vagrant", disabled: true
config.vm.define "tenant1" do |v|
v.vm.network :private_network, ip: "10.60.39.52"
v.vm.hostname = "tenant1"
v.vm.provider :virtualbox do |vb|
vb.customize ["modifyvm", :id, "--memory", 128]
end
v.vm.provision "shell", inline: $routes, args: "10.60.39.254"
end
config.vm.define "tenant2" do |v|
v.vm.network :private_network, ip: "10.23.42.52"
v.vm.hostname = "tenant2"
v.vm.provider :virtualbox do |vb|
vb.customize ["modifyvm", :id, "--memory", 128]
end
v.vm.provision "shell", inline: $routes, args: "10.23.42.254"
end
config.vm.define "rdomain-gw-left", primary: true do |v|
v.vm.network :private_network, ip: "10.23.42.254"
v.vm.network :private_network, ip: "10.60.39.254"
v.vm.network :private_network, ip: "10.0.123.254"
v.vm.hostname = "rdomain-gw-left"
v.vm.provider :virtualbox do |vb|
vb.customize ["modifyvm", :id, "--memory", 256]
vb.gui = true;
end
v.vm.provision "shell", inline: $routes
end
# "internet"
config.vm.define "rdomain-gw-right" do |v|
v.vm.network :private_network, ip: "10.0.123.253"
v.vm.network :private_network, ip: "172.19.82.254"
v.vm.hostname = "rdomain-gw-right"
v.vm.provider :virtualbox do |vb|
vb.customize ["modifyvm", :id, "--memory", 128]
end
v.vm.provision "shell", inline: $routes
end
config.vm.define "inetsrv" do |v|
v.vm.network :private_network, ip: "172.19.82.10"
v.vm.hostname = "inetsrv"
v.vm.provider :virtualbox do |vb|
vb.customize ["modifyvm", :id, "--memory", 128]
end
v.vm.provision "shell", inline: $routes, args: "172.19.82.254"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment