Creating Solaris 11 Vagrant boxes out of Unified Archives

I am using Vagrant with Virtualbox for many years to automate test environments on my notebook. I absolutely love it, it allows me to spin up Solaris and Linux virtual machines in any way I need it. If you also have a need for a very convenient and affordable LAB environment, give it a try.

There is an additional challenge if you want to use Solaris VMs. Because there are no prepared Solaris base images (aka boxes), which you could just download from the web. I assume it is legally not allowed to redistribute Solaris.

Luckily Solaris has already a very powerful technology for handling OS images Unified Archives (UARs), which you likely use already for your OS deployment. In this post I will show how you can convert a Unified Archive hands-free in approximately 10 minutes into a Vagrant box.

Last year Alan Chalmers published how to use the open source software “Packer” to create Vagrant boxes out of Solaris GA installation ISOs. I am building on this great work and extended it to use Unified Archives. I covered the installation of Solaris with UARs already in a previous article, the following Packer recipe does basically the same, but highly automated.

The method has several advantages:

  • Same image like in production, same SRU, same configuration, etc
  • SMF sysconfig profile can be used for clean re-configuration, like changing the hostname
  • Automated Installer (AI) manifest can be used for customizations, like changing the swap device, etc
  • Cleaner and more robust Packer configuration (e.g.: boot_command)
  • Plus all advantages of Unified Archives

First you need a UAR of your golden/master Solaris installation, with your customizations, like packages, patches, SRU, etc.

# archiveadm create /data/gold-image-v1.uar

When you have your archive file, you need to convert it first on Solaris to a boot-able ISO image:

# archiveadm create-media --format iso gold-image-v1.uar
Initiating media creation...
Preparing build environment...
Adding archive content...
Image preparation complete
Creating ISO image...
Finalizing /data/AI_Archive.iso...
Cleaning up...

When you have the iso file, check the paths and checksum in solaris-ai.json.

solaris-ai.json (shortened)link
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
{
"builders": [
{
"boot_command": [
"e<wait>",
"<down><down><down><down><down><wait>",
"<end>",
" -B install=true,aimanifest=http://{{ .HTTPIP }}:{{ .HTTPPort }}/manifest.xml,",
"profile=http://{{ .HTTPIP }}:{{ .HTTPPort }}/profile.xml",
"<f10>"
],
"boot_wait": "10s",
"disk_size": 8192,
"guest_os_type": "Solaris11_64",
"iso_url": "file://{{pwd}}/AI_Archive.iso",
"iso_checksum": "5439f20af74244dfc835c485f61ac939c3cb01e7644847e98d8f4e2fcb25f19e",
"iso_checksum_type": "sha256",
"http_directory": "http",
"shutdown_command": "sudo /usr/sbin/init 5",
"ssh_username": "vagrant",
"ssh_password": "vagrant01",
"ssh_port": 22,
"ssh_wait_timeout": "20m",
"type": "virtualbox-iso",
...
}
...
}

Then you can execute packer build. Quickly summarized, Packer boots a Virtualbox VM with the ISO, starts a web server to serve the AI manifest and the SMF sysconfig profile. Simulates keypresses for the special boot command and installs Vagrant specific stuff like Virtualbox Guest Additions and known Vagrant public key.

$ packer build -only=virtualbox-iso solaris-ai.json
...
==> Builds finished. The artifacts of successful builds are:
--> virtualbox-iso: VM files in directory: packer-solaris11-ai-virtualbox
--> virtualbox-iso: 'virtualbox' provider box: ./builds/virtualbox/solaris11_ai.box

When you execute the command you can lean back and watch how Packer creates your box. On my notebook with a flash disk, the build was finished in 12 minutes.

Finally your Vagrant Solaris base box is ready to use:

$ vagrant box add builds/virtualbox/solaris11_ai.box

If you like you can further customize the installation in the AI manifest http/manifest.xml and the SMF sysconfig profile http/profile.xml. The Packer recipe solaris-ai.json also contains a configuration for VMware, which should work, however I didn’t have the possibility to test it.

Github: solaris-packer

Share Comments