Skip to content

Instantly share code, notes, and snippets.

@carlos22
Created March 10, 2018 17:32
Show Gist options
  • Save carlos22/ec710b60fed6f751f2581f16b3964962 to your computer and use it in GitHub Desktop.
Save carlos22/ec710b60fed6f751f2581f16b3964962 to your computer and use it in GitHub Desktop.
SmartOS Vagrant Deploy Zone

Build zone with Vagrant

Requirements

  • Vagrant
  • VirtualBox (might work with vmware)
  • node.js/npm
  • sharutils (for dz; installed on most systems)

archlinux quick install:

pacman -S vagrant virtualbox sharutils npm

This is required because of the config.global_zone setting in the images Vagrantfile (otherwise not required)

vagrant plugin install vagrant-smartos-zones

Install dz (deploy-zone)

sudo npm install -g deploy-zone

Fire up VM and configure host in dz

vagrant up
vagrant ssh-config --host smartos.vagrant >> ~/.ssh/config
dz host add smartos.vagrant

Build

Build the zone. The mi-* repo should be in the current working folder (see .):

dz build --host smartos.vagrant -o /var/tmp/ .

Download image from VM

scp smartos.vagrant:/var/tmp/*.zfs.gz .
scp smartos.vagrant:/var/tmp/*.imgmanifest .

Install image (on smartos host)

imgadm install -m /var/tmp/<imgname>.imgmanifest -f /var/tmp/<imgname>.zfs.gz
# provision
$script = <<SCRIPT
echo "add skylime imgadm source"
imgadm sources -a "https://imgapi.smartos.skylime.net/"
echo "create external nictag (with i-net access)"
nictagadm delete admin
nictagadm add admin "$(dladm show-phys -m -o ADDRESS -p e1000g1)"
nictagadm add external "$(dladm show-phys -m -o ADDRESS -p e1000g0)"
SCRIPT
Vagrant.configure("2") do |config|
config.vm.box = "drscream/smartos"
config.vm.box_version = "20180203.031130"
# network for nictag admin (internal host-only network)
config.vm.network "private_network", type: "dhcp"
# disable syned folder (because it requires nfs and we should not need it)
config.vm.synced_folder ".", "/vagrant", disabled: true
# provision
config.vm.provision "shell", inline: $script, privileged: false # sudo is not availible in smartos-gz
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment