Browse the Repo

file-type-icon.circleci
file-type-icon_ci
file-type-icon_docs
file-type-iconexamples
file-type-iconmodules
file-type-iconinstall-nomad
file-type-iconREADME.md
file-type-iconinstall-nomad
file-type-iconsupervisor-initd-script.sh
file-type-iconsupervisord.conf
file-type-iconnomad-cluster
file-type-iconnomad-security-group-rules
file-type-iconrun-nomad
file-type-icontest
file-type-icon.gitignore
file-type-iconCODEOWNERS
file-type-iconCONTRIBUTING.md
file-type-iconLICENSE
file-type-iconNOTICE
file-type-iconREADME.md
file-type-iconcore-concepts.md
file-type-iconmain.tf
file-type-iconoutputs.tf
file-type-iconvariables.tf

Browse the Repo

file-type-icon.circleci
file-type-icon_ci
file-type-icon_docs
file-type-iconexamples
file-type-iconmodules
file-type-iconinstall-nomad
file-type-iconREADME.md
file-type-iconinstall-nomad
file-type-iconsupervisor-initd-script.sh
file-type-iconsupervisord.conf
file-type-iconnomad-cluster
file-type-iconnomad-security-group-rules
file-type-iconrun-nomad
file-type-icontest
file-type-icon.gitignore
file-type-iconCODEOWNERS
file-type-iconCONTRIBUTING.md
file-type-iconLICENSE
file-type-iconNOTICE
file-type-iconREADME.md
file-type-iconcore-concepts.md
file-type-iconmain.tf
file-type-iconoutputs.tf
file-type-iconvariables.tf
HashiCorp Nomad

HashiCorp Nomad

Deploy a Nomad cluster. Supports automatic bootstrapping, discovery of Consul servers, automatic recovery of failed servers.

Code Preview

Preview the Code

mobile file icon

README.md

down

Nomad Install Script

This folder contains a script for installing Nomad and its dependencies. You can use this script, along with the run-nomad script it installs to create a Nomad Amazon Machine Image (AMI) that can be deployed in AWS across an Auto Scaling Group using the nomad-cluster module.

This script has been tested on the following operating systems:

  • Ubuntu 16.04
  • Ubuntu 18.04
  • Amazon Linux

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

Quick start

To install Nomad, use git to clone this repository at a specific tag (see the releases page for all available tags) and run the install-nomad script:

git clone --branch <VERSION> https://github.com/hashicorp/terraform-aws-nomad.git
terraform-aws-nomad/modules/install-nomad/install-nomad --version 0.5.4

The install-nomad script will install Nomad, its dependencies, and the run-nomad script. You can then run the run-nomad script when the server is booting to start Nomad and configure it to automatically join other nodes to form a cluster.

We recommend running the install-nomad script as part of a Packer template to create a Nomad Amazon Machine Image (AMI) (see the nomad-consul-ami example for sample code). You can then deploy the AMI across an Auto Scaling Group using the nomad-cluster module (see the nomad-consul-colocated-cluster and nomad-consul-separate-cluster examples for fully-working sample code).

Command line Arguments

The install-nomad script accepts the following arguments:

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

Example:

install-nomad --version 0.5.4

How it works

The install-nomad script does the following:

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

Create a user and folders for Nomad

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

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

Install Nomad binaries and scripts

Install the following:

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

Install supervisord

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

Follow-up tasks

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

  1. If you have custom Nomad config (.hcl) files, you may want to copy them into the config directory (default: /opt/nomad/config).
  2. If /usr/local/bin isn't already part of PATH, you should add it so you can run the nomad 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.

Questions? Ask away.

We're here to talk about our services, answer any questions, give advice, or just to chat.

Ready to hand off the Gruntwork?