This is a Packer post-processor plugin to upload versioned boxes to Google Compute Storage (GCS).
- Download binaries from the releases page.
- Install the plugin, or simply put it into the same directory with JSON templates.
- Move the downloaded binary to
~/.packer.d/plugins/
Clone repository and build
$ mkdir -p $GOPATH/src/github.com/arnaud-dezandee; cd $GOPATH/src/github.com/arnaud-dezandee
$ git clone git@github.com:arnaud-dezandee/packer-vagrant-box-gcs.git$ cd $GOPATH/src/github.com/arnaud-dezandee/packer-vagrant-box-gcs
$ go installLink the build to Packer
$ ln -s $GOPATH/bin/packer-vagrant-box-gcs ~/.packer.d/plugins/packer-post-processor-vagrant-box-gcs Add the plugin to your packer template after vagrant post-processor
{
"builder": [{
"type": "virtualbox-iso"
}],
"post-processors": [
[
{
"type": "vagrant"
},
{
"type": "vagrant-box-gcs",
"box_name": "myorg/mybox",
"bucket": "my-gcs-bucket",
"version": "1.0.0"
}
]
]
}This will create two objects inside the bucket
gs://my-gcs-bucket/myorg/mybox
gs://my-gcs-bucket/myorg/boxes/mybox/1.0.0/virtualbox.box
With the help of vagrant-box-gcs plugin, you can now point your Vagrantfile to the manifest
Vagrant.configure(2) do |config|
config.vm.box = "myorg/mybox"
config.vm.box_url = "gs://my-gcs-bucket/myorg/mybox"
endAuthenticating with Google Cloud services requires at most one JSON file. Packer will look for credentials in the following places, preferring the first location found:
-
An
account_fileoption in your packer file. -
A JSON file (Service Account) whose path is specified by the
GOOGLE_APPLICATION_CREDENTIALSenvironment variable. -
A JSON file in a location known to the
gcloudcommand-line tool. (gcloud auth application-default logincreates it)On Windows, this is:
%APPDATA%/gcloud/application_default_credentials.jsonOn other systems:
$HOME/.config/gcloud/application_default_credentials.json -
On Google Compute Engine and Google App Engine Managed VMs, it fetches credentials from the metadata server. (Needs a correct VM authentication scope configuration)
There are many configuration options available for the plugin. They are segmented below into two categories: required and optional parameters.
-
box_name(string) - The name of your box. (e.g.hashicorp/precise64) -
bucket(string) - The GCS bucket name where files will be uploaded to. -
version(string) - The version of the box you are uploading. (e.g.1.0.0)
-
account_file(string) - The JSON file containing your account credentials. -
box_dir(string) - The path to a directory in your bucket to store boxes.Defaults to
{{ box_name[org] }}/boxes/{{ box_name[title] }}/{{ version }}. -
box_manifest(string) - The path to the manifest file in your bucket.Defaults to
{{ box_name }}.
- vagrant-box-gcs - Vagrant plugin to download boxes from Google GCS.
- packer-post-processor-vagrant-s3 - A Packer post-processor to upload vagrant boxes to S3.