Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Habitat 3-node supervisor ring in Vagrant/Virtualbox
$script = <<SCRIPT
groupadd hab
useradd hab -g hab
curl https://raw.githubusercontent.com/habitat-sh/habitat/master/components/hab/install.sh | bash
hab pkg install core/cacerts
hab pkg install core/hab-sup
cat <<EOT > /hab/cache/keys/vagrantring-20180621073652.sym.key
SYM-SEC-1
vagrantring-20180621073652
HAIT1DGNzGtHkZ64kXIKyW8erkyRnOO0I+SRXMK/wVg=
EOT
chmod 400 /hab/cache/keys/vagrantring-20180621073652.sym.key
mkdir -p /etc/systemd/system
cat <<EOT > /etc/systemd/system/hab-sup.service
[Unit]
Description=Habitat Supervisor
[Service]
ExecStartPre=/bin/bash -c "/bin/systemctl set-environment SSL_CERT_FILE=$(hab pkg path core/cacerts)/ssl/cert.pem"
ExecStart=/bin/hab run \
--ring vagrantring \
--peer 172.20.20.10 \
--url https://bldr.habitat.sh \
--channel stable \
--auto-update
# --events eventsrv.default
[Install]
WantedBy=default.target
EOT
systemctl daemon-reload
systemctl restart hab-sup
SCRIPT
Vagrant.configure('2') do |config|
config.vm.box = 'ubuntu/bionic64'
config.vm.box_check_update = false
config.vm.provision 'shell', inline: $script
config.vm.define 'hab0' do |hab0|
hab0.vm.hostname = 'hab0'
hab0.vm.network 'private_network', ip: '172.20.20.10'
hab0.vm.network 'forwarded_port', guest: 9631, host: 9631 # HTTP Gateway
hab0.vm.network 'forwarded_port', guest: 9632, host: 9632 # Control Gateway
hab0.vm.network 'forwarded_port', guest: 9638, host: 9638 # Gossip
end
config.vm.define 'hab1' do |hab1|
hab1.vm.hostname = 'hab1'
hab1.vm.network 'private_network', ip: '172.20.20.11'
hab1.vm.network 'forwarded_port', guest: 9631, host: 19631 # HTTP Gateway
hab1.vm.network 'forwarded_port', guest: 9632, host: 19632 # Control Gateway
hab1.vm.network 'forwarded_port', guest: 9638, host: 19638 # Gossip
end
config.vm.define 'hab2' do |hab2|
hab2.vm.hostname = 'hab2'
hab2.vm.network 'private_network', ip: '172.20.20.12'
hab2.vm.network 'forwarded_port', guest: 9631, host: 29631 # HTTP Gateway
hab2.vm.network 'forwarded_port', guest: 9632, host: 29632 # Control Gateway
hab2.vm.network 'forwarded_port', guest: 9638, host: 29638 # Gossip
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment