Need Liquibase® support? Liquibase Pro is now available! Try it out free.
2018 XML Announcement

Liquibase SDK Vagrant

The Liquibase SDK uses Vagrant to manage database servers. Vagrant configurations can be auto-generated via the liquibase-sdk vagrant BOX_NAME init command and started with liquibase-sdk vagrant BOX_NAME up.

For convenience, the liquibase-sdk application will execute standard vagrant commands such as up, destroy, halt, and provision.

Within the Liquibase SDK directory structure, vagrant boxes are stored as subdirectories under LIQUIBASE_HOME/sdk/vagrant. There is a special “LIQUIBASE_HOME/sdk/install-files” directory which is used for storing files that cannot be freely downloaded from the Internet. The output from the init command should list anything that needs to be stored in the install-files directory for your configuration.

Liquibase SDK is available in Liquibase 3.2.0+

Standard Vagrant Box Configuration

  • Most Vagrant boxes are created with host-only networking on IP 10.10.100.100.
  • Firewalls are disabled to limit unexpected errors and because the network is host-only.
  • A “liquibase” OS user is created with password “liquibase”
  • A “lbuser” database user is created with a password of “lbuser”
  • An alternate “lbuser2” database user is created with a password of “lbuser2”
  • A catalog of “lbcat” is created if the database supports catalogs
  • An alternate catalog of “lbcat2” is created if the database supports catalogs
  • A schema of “lbschema” is created if the databases supports schemas
  • An alternate schema of “lbschema2” is created if the databases supports schemas

__Each database configuration may vary from these standards. Check the output of liquibase-sdk vagrant BOX_NAME init to confirm configuration.

Expected Vagrant Base Box Definitions

The vagrant configurations generated by liquibase-sdk vagrant BOX_NAME init do not include a base box URL. This means you need to run vagrant box add BASE_BOX_NAME URL for each base box name Liquibase will create boxes for.

Liquibase uses the following box definitions:

  • liquibase.linux.centos.x64
  • liquibase.windows.2008r2.x64 (see below for information on creating a base windows box)

Example: vagrant box add liquibase.linux.centos.x64 http://developer.nrel.gov/downloads/vagrant-boxes/CentOS-6.4-x86_64-v20130731.box

Available Commands

liquibase-sdk vagrant [BOX_NAME] init –databases=[CONFIGURATION(s)]

The vagrant BOX_NAME init command will create a new vagrant box for the given configurations. This is a Liquibase SDK specific command and does not simply call the standard vagrant init command. Multiple configurations can be listed as a comma separated list. Parameters to each configuration are defined in [square brackets]. Re-running vagrant BOX_NAME init will overwrite any changes you may have made to files in the LIQUIBASE_SDK/vagrant/BOX_NAME directory.

Examples:

  • vagrant mysql init --databases=mysql
  • vagrant oss-db init --databases=mysql,postgres
  • vagrant mysql-win init --databases=mysql[config:windows]

liquibase-sdk vagrant [BOX_NAME] up

Start a vagrant box previously created with the vagrant BOX_NAME init command

Examples:

  • vagrant mysql-windows up
  • vagrant oss-db up

liquibase-sdk vagrant [BOX_NAME] destroy

Stops the running vagrant box and destroys all resources that were created during the machine creation process. Does not delete the box configuration.

liquibase-sdk vagrant [BOX_NAME] halt

Shuts down the running vagrant box.

liquibase-sdk vagrant [BOX_NAME] suspend

Suspends the given vagrant box, rather than fully shutting it down or destroying it.

liquibase-sdk vagrant [BOX_NAME] resume

Resumes the given vagrant box. Normally resumes from the suspend command

liquibase-sdk vagrant status

Returns the state of the machines Vagrant is managing

liquibase-sdk vagrant [BOX_NAME] reload

Equivalent of halt followed by an up. This is normally not a command you need to run unless you are manually changing your generated configuration files.

liquibase-sdk vagrant [BOX_NAME] provision

Re-runs the defined vagrant provisioners. This is normally not a command you need to run unless you are manually changing your generated configuration files.

Base Windows Vagrant Box

To run windows-based databases, you need a base windows box. The easiest way is to download the Windows 2008R2 180 day trial image from http://www.microsoft.com/en-us/download/confirmation.aspx?id=16572. Since it is a trial that times out, you will need to re-do this process every 180 days. If you have a valid MSDN license you can use the same process to create a image that does not time out.

Once downloaded, create a new VirtualBox machine to be your vagrant base box. In the initial wizard, do not create or a virtual hard drive because attaching the .vhd you downloaded will attach it as a SATA drive which does not boot. Once it is created, go to the Storage settings and add the downloaded .vhd in the IDE controller. The trial server Administrator password is Pass@word1

Before “vagrant package”:

  1. Make sure to set the host name to “vagrant” and create a “vagrant” user as administrator. You will need to run secpol.msc and change the Password Policy under “Account Policies”
  2. Install VirtualBox guest tools
  3. Disable audio and USB (need to change mouse to ps/2 to disable usb)
  4. Activate Windows
  5. Install windows updates (it may take several rounds)
  6. Disable firewall
  7. Install puppet from http://puppetlabs.com/misc/download-options
  8. Enable remote desktop
  9. Package with: vagrant package --base YOUR_VIRTUALBOX_MACHINE_NAME
  10. Install with: vagrant box add liquibase.windows.2008r2.x64 package.box

Vagrant Configuration Details

Provisioning in Vagrant is handed primarily by puppet. The Vagrantfile contains only a shell provisioner, but it does a small amount of setup to bootstrap puppet then runs puppet. The starting puppet file is manifests/init.pp within each vagrant box.


Missing, incomplete or wrong information? Please send a pull request