github.com/devopsbq/packer_doconsul

A Packer Post Processor for storing DigitalOcean image IDs into Consul.


Install
go get github.com/devopsbq/packer_doconsul

Documentation

packer_doconsul

A Packer Post Processor for storing DigitalOcean and AWS image IDs into Consul. The implementation is based on packer-post-processor-consul's, from bhourigan, and extends his implementation to DigitalOcean provider.

This post-processor takes an image from DigitalOcean's builder or Amazon Web services's builder and stores its ID in Consul, within the path snaps/[do|aws]/<region>/<snapshot_name>/<snapshot_version>.

Features

  • TLS support for secure communication with the Consul API.
  • Token support for Consul ACLs.

Installation

The first thing you need to do is to build the source code and name it correctly for Packer to be able to detect it as a plugin:

cd packer_doconsul
go get
go build
mv packer_doconsul ~/.packer.d/plugins/packer-post-processor-doconsul

For more information about installing the plugin, please check Packer's Plugins documentation.

Configuration

The following parameters are required:

  • snapshot_name: The name you wish to give to your snapshot.

The following parameters are optional:

  • consul_address: The address of your Consul deployment. By default, 127.0.0.1:8500
  • consul_scheme: The Consul scheme. This can be either http, or https. By default, http.
  • consul_token: The token for communication with Consul, if needed.
  • snapshot_version: The version you wish to give to your snapshot. By default, latest.
  • ca_file: A file path to a PEM-encoded certificate authority.
  • cert_file: A file path to a PEM-encoded certificate.
  • key_file: A the file path to a PEM-encoded private key.
  • skip_tls_verify: Skip server-side certificate validation.
  • ignore_connection_errors: Skip Consul connection errors. This boolean option makes this post-processor ignoring errors if Consul is unavailable, so it does nothing. By default this is false.

Remember that this post-processor will store your DigitalOcean's image ID at path snaps/[do|aws]/<region>/<snapshot_name>/<snapshot_version>.

Basic example

Here is a basic example. As you can see, you can do interpolation for computing the value of the fields.

"post-processors": [
  {
    "type": "doconsul",
    "snapshot_name": "{{user `snap_name`}}",
    "snapshot_version": "0.1.0",
    "consul_address": "{{user `consul_address`}}:{{user `consul_port`}}"
  }
]