Skip to content
Branch: master
Find file History
Type Name Latest commit message Commit time
Failed to load latest commit information. update references to ubuntu on docs Jul 25, 2019
install-consul update references to ubuntu on docs Jul 25, 2019

Consul Install Script

This folder contains a script for installing Consul and its dependencies. Use this script along with the run-consul script to create a Consul Google Image that can be deployed in GCP across a Managed Instance Scaling Group using the consul-cluster module.

This script has been tested on the following operating systems:

  • Ubuntu 16.04
  • Ubuntu 18.04

There is a good chance it will work on other flavors of Debian as well.

Quick start

To install Consul, use git clone --branch to clone this repository at a specific tag run the install-consul script:

git clone --branch <MODULE_VERSION>
terraform-google-consul/modules/install-consul/install-consul --version 1.10.0

The install-consul script will install Consul, its dependencies, and the run-consul script. The run-consul script is also run when the server is booting to start Consul and configure it to automatically join other nodes to form a cluster.

We recommend running the install-consul script as part of a Packer template to create a Consul Image (see the consul-image example for fully-working sample code). You can then deploy the Image across a Managed Instance Group using the consul-cluster module (see the consul-cluster example for fully-working sample code).

Command line Arguments

The install-consul script accepts the following arguments:

  • version VERSION: Install Consul version VERSION. Required.
  • path DIR: Install Consul into folder DIR. Optional.
  • user USER: The install dirs will be owned by user USER. Optional.


install-consul --version 1.10.0

How it works

The install-consul script does the following:

  1. Create a user and folders for Consul
  2. Install Consul binaries and scripts
  3. Install supervisord
  4. Follow-up tasks

Create a user and folders for Consul

Create an OS user named consul. Create the following folders, all owned by user consul:

  • /opt/consul: base directory for Consul data (configurable via the --path argument).
  • /opt/consul/bin: directory for Consul binaries.
  • /opt/consul/data: directory where the Consul agent can store state.
  • /opt/consul/config: directory where the Consul agent looks up configuration.
  • /opt/consul/log: directory where Consul will store log output.

Install Consul binaries and scripts

Install the following:

  • consul: Download the Consul zip file from the downloads page (the version number is configurable via the --version argument), and extract the consul binary into /opt/consul/bin. Add a symlink to the consul binary in /usr/local/bin.
  • run-consul: Copy the run-consul script into /opt/consul/bin.

Install supervisord

Install supervisord. We use it as a cross-platform supervisor to ensure Consul is started whenever the system boots and restarted if the Consul process crashes.

Follow-up tasks

After the install-consul script finishes running, you may wish to do the following:

  1. If you have custom Consul config (.json) files, you may want to copy them into the config directory (default: /opt/consul/config).
  2. If /usr/local/bin isn't already part of PATH, you should add it so you can run the consul command without specifying the full path.

Why use Git to install this code?

We needed an easy way to install these scripts that satisfied a number of requirements, including working on a variety of operating systems and supported versioning. Our current solution is to use git, but this may change in the future. See Package Managers for a full discussion of the requirements, trade-offs, and why we picked git.

You can’t perform that action at this time.