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.
To install Consul, use
git clone --branch to clone this repository at a specific tag run the
git clone --branch <MODULE_VERSION> https://github.com/hashicorp/terraform-google-consul.git terraform-google-consul/modules/install-consul/install-consul --version 1.10.0
install-consul script will install Consul, its dependencies, and the run-consul script.
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
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
install-consul script does the following:
- Create a user and folders for Consul
- Install Consul binaries and scripts
- Install supervisord
- Follow-up tasks
Create a user and folders for Consul
Create an OS user named
consul. Create the following folders, all owned by user
/opt/consul: base directory for Consul data (configurable via the
/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
--versionargument), and extract the
/opt/consul/bin. Add a symlink to the
run-consul: Copy the run-consul script into
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.
install-consul script finishes running, you may wish to do the following:
- If you have custom Consul config (
.json) files, you may want to copy them into the config directory (default:
/usr/local/binisn't already part of
PATH, you should add it so you can run the
consulcommand 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