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:
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.
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.
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:
If you have custom Nomad config (.hcl) files, you may want to copy them into the config directory (default:
/opt/nomad/config).
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.
{"treedata":{"name":"root","toggled":true,"children":[{"name":".circleci","children":[{"name":"config.yml","path":".circleci/config.yml","sha":"20968ed882b09a03245770f84b523b73cd64df78"}]},{"name":".gitignore","path":".gitignore","sha":"6c4ebe4426586b7febbaba178294ef59b8272c05"},{"name":"CODEOWNERS","path":"CODEOWNERS","sha":"5949dbc0fa6d4dd6610575e3c878c353d92da44a"},{"name":"CONTRIBUTING.md","path":"CONTRIBUTING.md","sha":"4c6520097a38c2b63e7a91e20a4c06f8005e6fe4"},{"name":"LICENSE","path":"LICENSE","sha":"7a4a3ea2424c09fbe48d455aed1eaa94d9124835"},{"name":"NOTICE","path":"NOTICE","sha":"4653ef2dace926e046f74ab82c82647558c7e94f"},{"name":"README.md","path":"README.md","sha":"48583f19e9257d330a8d9e6f041b101932490d56"},{"name":"_ci","children":[{"name":"publish-amis-in-new-account.md","path":"_ci/publish-amis-in-new-account.md","sha":"3182a0a90775f7bb9622c037196ac2a1f15e455d"},{"name":"publish-amis.sh","path":"_ci/publish-amis.sh","sha":"6902cb1e3d7624ecc91096bcd48c5c91e248c653"}]},{"name":"_docs","children":[{"name":"amazon-linux-ami-list.md","path":"_docs/amazon-linux-ami-list.md","sha":"6607a70497e27d57222552281825053783ad7bb2"},{"name":"architecture-nomad-consul-colocated.png","path":"_docs/architecture-nomad-consul-colocated.png","sha":"438a8b71d1afdc7f91065b910e9de2d6d7d9517c"},{"name":"architecture-nomad-consul-separate.png","path":"_docs/architecture-nomad-consul-separate.png","sha":"df28d183fb8090fabc457ee56f3fb43ded6a5b13"},{"name":"architecture.png","path":"_docs/architecture.png","sha":"e539a77e88af6849d0893be35a8c5b5270edb195"},{"name":"nomad-icon.png","path":"_docs/nomad-icon.png","sha":"193298e1f719d6fb51513d0d9631dafaa17cfaf3"},{"name":"ubuntu16-ami-list.md","path":"_docs/ubuntu16-ami-list.md","sha":"4c1af1d6d863e0e6120520b65d823ee2ae2e2079"}]},{"name":"core-concepts.md","path":"core-concepts.md","sha":"314e6e4769a0316adbce0ff39196f1821544c9ce"},{"name":"examples","children":[{"name":"nomad-consul-ami","children":[{"name":"README.md","path":"examples/nomad-consul-ami/README.md","sha":"3e1ffc13902ee7ff46ef750a1e03d316ff4afedf"},{"name":"nomad-consul-docker.json","path":"examples/nomad-consul-ami/nomad-consul-docker.json","sha":"89df67eabeeb9e07f039dbe085e1932f592992d3"},{"name":"nomad-consul.json","path":"examples/nomad-consul-ami/nomad-consul.json","sha":"58a462d3443bf5f067f24f438919aab6c696b715"},{"name":"setup_amazon-linux.sh","path":"examples/nomad-consul-ami/setup_amazon-linux.sh","sha":"afa4e86365348ab91616f08d3fae0a28c64e158f"},{"name":"setup_nomad_consul.sh","path":"examples/nomad-consul-ami/setup_nomad_consul.sh","sha":"c4e68a5affa34caab8e4197028dfc1970c33da6e"},{"name":"setup_ubuntu.sh","path":"examples/nomad-consul-ami/setup_ubuntu.sh","sha":"81268f86b1ccf5a567ec913dd1dbbe3b3868ad93"}]},{"name":"nomad-consul-separate-cluster","children":[{"name":"README.md","path":"examples/nomad-consul-separate-cluster/README.md","sha":"4f8ee73c20f575cb86ed28fb05840d093e6f2f15"},{"name":"main.tf","path":"examples/nomad-consul-separate-cluster/main.tf","sha":"c29c23f9c54e171826309ed3f00a13552b3c6147"},{"name":"outputs.tf","path":"examples/nomad-consul-separate-cluster/outputs.tf","sha":"fab958b55d52594d98df8391c4282e5c4c1f008a"},{"name":"user-data-consul-server.sh","path":"examples/nomad-consul-separate-cluster/user-data-consul-server.sh","sha":"659e77d66aa4140f776cfbeb9e71f1a874b00682"},{"name":"user-data-nomad-client.sh","path":"examples/nomad-consul-separate-cluster/user-data-nomad-client.sh","sha":"c52069299ee4fe73fbd9cd5d4f48be8ef6a35b3d"},{"name":"user-data-nomad-server.sh","path":"examples/nomad-consul-separate-cluster/user-data-nomad-server.sh","sha":"1b99ff7d6b56999da42c04d5405e81c738214af1"},{"name":"variables.tf","path":"examples/nomad-consul-separate-cluster/variables.tf","sha":"78d0882b72b80b9b8eea67d4950e15b826647e1d"}]},{"name":"nomad-examples-helper","children":[{"name":"README.md","path":"examples/nomad-examples-helper/README.md","sha":"4b42111e7abf289798df0c62847edc722bcd6256"},{"name":"example.nomad","path":"examples/nomad-examples-helper/example.nomad","sha":"63958e3d491757da48a72255ec3b8882302ba33e"},{"name":"nomad-examples-helper.sh","path":"examples/nomad-examples-helper/nomad-examples-helper.sh","sha":"7f5f10afb2331d88268d53fe7e7d8deb0585a8db"}]},{"name":"root-example","children":[{"name":"README.md","path":"examples/root-example/README.md","sha":"9c2e4ffd4e0ffcf6e4d4a6d31583205251a6c67d"},{"name":"user-data-client.sh","path":"examples/root-example/user-data-client.sh","sha":"d6bac10fb2bb654d3255052d863ab19c9cdd41bc"},{"name":"user-data-server.sh","path":"examples/root-example/user-data-server.sh","sha":"109bdeb1f8df56b35d6bf1a6e5346cae4aca61f5"}]}]},{"name":"main.tf","path":"main.tf","sha":"5b21e3855375c578f5946961181efd25ad8426bc"},{"name":"modules","children":[{"name":"install-nomad","children":[{"name":"README.md","path":"modules/install-nomad/README.md","sha":"f793a3975dc6d8a06873a7f6a8ef1892eba01d84","toggled":true},{"name":"install-nomad","path":"modules/install-nomad/install-nomad","sha":"5a74c98520010121d95d3432f08dffced7c2f761"},{"name":"supervisor-initd-script.sh","path":"modules/install-nomad/supervisor-initd-script.sh","sha":"171b91613e98ab2bd10282025caff1707918c95a"},{"name":"supervisord.conf","path":"modules/install-nomad/supervisord.conf","sha":"d96beb0ca9a16279ed1bdf74cbb6516275d85085"}],"toggled":true},{"name":"nomad-cluster","children":[{"name":"README.md","path":"modules/nomad-cluster/README.md","sha":"e47de8d5174ca6020601898c386a8de2e06f021d"},{"name":"main.tf","path":"modules/nomad-cluster/main.tf","sha":"e46194c1170b25016dd4ed1dfb068af1583d47a6"},{"name":"outputs.tf","path":"modules/nomad-cluster/outputs.tf","sha":"341778300126873e11e2cf9d964bccd927c2644e"},{"name":"variables.tf","path":"modules/nomad-cluster/variables.tf","sha":"b0293a8dc30f988ca63af42e06e7a7cefaabde91"}]},{"name":"nomad-security-group-rules","children":[{"name":"README.md","path":"modules/nomad-security-group-rules/README.md","sha":"c35eab862bdd870569408a9ad55e8abb6894e4fe"},{"name":"main.tf","path":"modules/nomad-security-group-rules/main.tf","sha":"51438a98f6defe8045c21437e4b1d95b3f42061c"},{"name":"variables.tf","path":"modules/nomad-security-group-rules/variables.tf","sha":"a3d9d4b0b2abcce058d41b61b099fa115a7babd3"}]},{"name":"run-nomad","children":[{"name":"README.md","path":"modules/run-nomad/README.md","sha":"c66430e400076f3afbbfa9ff55abcc2aec7564f2"},{"name":"run-nomad","path":"modules/run-nomad/run-nomad","sha":"0216b1713f86310fa21fba9d4feacbffc45c9067"}]}],"toggled":true},{"name":"outputs.tf","path":"outputs.tf","sha":"f3efe59a6784255e79e0a7a77cf4b4ce2461278f"},{"name":"test","children":[{"name":"Gopkg.lock","path":"test/Gopkg.lock","sha":"fc3214f34d7c2f6d5d1c1ab6f9ecf1a85bfb06f8"},{"name":"Gopkg.toml","path":"test/Gopkg.toml","sha":"a84c6ed7e5bfce6f72e9e08666f1665af01a3f84"},{"name":"README.md","path":"test/README.md","sha":"874818e6da7a9c0c9338edde0c27fa3f8a3b3d05"},{"name":"aws_helpers.go","path":"test/aws_helpers.go","sha":"c7b6601bf58485e5deddbb1e17f433b0c12c9dae"},{"name":"nomad_consul_cluster_colocated_test.go","path":"test/nomad_consul_cluster_colocated_test.go","sha":"365b422c08e52295c1ff0bb211df4d5c973766a9"},{"name":"nomad_consul_cluster_separate_test.go","path":"test/nomad_consul_cluster_separate_test.go","sha":"0750f6f9bc45a650355e0d3c2557abae45ac7e73"},{"name":"nomad_helpers.go","path":"test/nomad_helpers.go","sha":"1750e3d729d429c9062fde804f4a66a0d514d22d"},{"name":"terratest_helpers.go","path":"test/terratest_helpers.go","sha":"f6e176e37bc9ce4c5322834a0325bc9ff1b836b4"}]},{"name":"variables.tf","path":"variables.tf","sha":"0941f7c8577a1db5d7fdafbd274deb87813c0ca9"}]},"detailsContent":"<h1 class=\"preview__body--title\" id=\"nomad-install-script\">Nomad Install Script</h1><div class=\"preview__body--border\"></div><p>This folder contains a script for installing Nomad and its dependencies. You can use this script, along with the\n<a href=\"/repos/v0.5.2/terraform-aws-nomad/modules/run-nomad\" class=\"preview__body--description--blue\">run-nomad script</a> it installs to create a Nomad <a href=\"http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/AMIs.html\" class=\"preview__body--description--blue\" target=\"_blank\">Amazon Machine Image\n(AMI)</a> that can be deployed in\n<a href=\"https://aws.amazon.com/\" class=\"preview__body--description--blue\" target=\"_blank\">AWS</a> across an Auto Scaling Group using the <a href=\"/repos/v0.5.2/terraform-aws-nomad/modules/nomad-cluster\" class=\"preview__body--description--blue\">nomad-cluster module</a>.</p>\n<p>This script has been tested on the following operating systems:</p>\n<ul>\n<li>Ubuntu 16.04</li>\n<li>Ubuntu 18.04</li>\n<li>Amazon Linux</li>\n</ul>\n<p>There is a good chance it will work on other flavors of Debian, CentOS, and RHEL as well.</p>\n<h2 class=\"preview__body--subtitle\" id=\"quick-start\">Quick start</h2>\n<p></p>\n<p>To install Nomad, use <code>git</code> to clone this repository at a specific tag (see the <a href=\"/repos/releases\" class=\"preview__body--description--blue\">releases page</a>\nfor all available tags) and run the <code>install-nomad</code> script:</p>\n<pre>git clone --branch <VERSION> https://github.com/hashicorp/<span class=\"hljs-keyword\">terraform</span>-aws-nomad.git\n<span class=\"hljs-keyword\">terraform</span>-aws-nomad/modules/install-nomad/install-nomad --version <span class=\"hljs-number\">0.5</span>.<span class=\"hljs-number\">4</span>\n</pre>\n<p>The <code>install-nomad</code> script will install Nomad, its dependencies, and the <a href=\"/repos/v0.5.2/terraform-aws-nomad/modules/run-nomad\" class=\"preview__body--description--blue\">run-nomad script</a>.\nYou can then run the <code>run-nomad</code> script when the server is booting to start Nomad and configure it to automatically\njoin other nodes to form a cluster.</p>\n<p>We recommend running the <code>install-nomad</code> script as part of a <a href=\"https://www.packer.io/\" class=\"preview__body--description--blue\" target=\"_blank\">Packer</a> template to create a\nNomad <a href=\"http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/AMIs.html\" class=\"preview__body--description--blue\" target=\"_blank\">Amazon Machine Image (AMI)</a> (see the\n<a href=\"/repos/v0.5.2/terraform-aws-nomad/examples/nomad-consul-ami\" class=\"preview__body--description--blue\">nomad-consul-ami example</a> for sample code). You can then deploy the AMI across an Auto\nScaling Group using the <a href=\"/repos/v0.5.2/terraform-aws-nomad/modules/nomad-cluster\" class=\"preview__body--description--blue\">nomad-cluster module</a> (see the\n<a href=\"/repos/v0.5.2/terraform-aws-nomad/MAIN.md\" class=\"preview__body--description--blue\">nomad-consul-colocated-cluster</a> and\n<a href=\"/repos/v0.5.2/terraform-aws-nomad/examples/nomad-consul-separate-cluster\" class=\"preview__body--description--blue\">nomad-consul-separate-cluster</a> examples for fully-working sample code).</p>\n<h2 class=\"preview__body--subtitle\" id=\"command-line-arguments\">Command line Arguments</h2>\n<p>The <code>install-nomad</code> script accepts the following arguments:</p>\n<ul>\n<li><code>version VERSION</code>: Install Nomad version VERSION. Required.</li>\n<li><code>path DIR</code>: Install Nomad into folder DIR. Optional.</li>\n<li><code>user USER</code>: The install dirs will be owned by user USER. Optional.</li>\n</ul>\n<p>Example:</p>\n<pre>install-nomad --version <span class=\"hljs-number\">0.5</span><span class=\"hljs-number\">.4</span>\n</pre>\n<h2 class=\"preview__body--subtitle\" id=\"how-it-works\">How it works</h2>\n<p>The <code>install-nomad</code> script does the following:</p>\n<ol>\n<li><a href=\"#create-a-user-and-folders-for-nomad\" class=\"preview__body--description--blue\">Create a user and folders for Nomad</a></li>\n<li><a href=\"#install-nomad-binaries-and-scripts\" class=\"preview__body--description--blue\">Install Nomad binaries and scripts</a></li>\n<li><a href=\"#install-supervisord\" class=\"preview__body--description--blue\">Install supervisord</a></li>\n<li><a href=\"#follow-up-tasks\" class=\"preview__body--description--blue\">Follow-up tasks</a></li>\n</ol>\n<h3 class=\"preview__body--subtitle\" id=\"create-a-user-and-folders-for-nomad\">Create a user and folders for Nomad</h3>\n<p>Create an OS user named <code>nomad</code>. Create the following folders, all owned by user <code>nomad</code>:</p>\n<ul>\n<li><code>/opt/nomad</code>: base directory for Nomad data (configurable via the <code>--path</code> argument).</li>\n<li><code>/opt/nomad/bin</code>: directory for Nomad binaries.</li>\n<li><code>/opt/nomad/data</code>: directory where the Nomad agent can store state.</li>\n<li><code>/opt/nomad/config</code>: directory where the Nomad agent looks up configuration.</li>\n<li><code>/opt/nomad/log</code>: directory where the Nomad agent will store log files.</li>\n</ul>\n<h3 class=\"preview__body--subtitle\" id=\"install-nomad-binaries-and-scripts\">Install Nomad binaries and scripts</h3>\n<p>Install the following:</p>\n<ul>\n<li><code>nomad</code>: Download the Nomad zip file from the <a href=\"https://www.nomadproject.io/downloads.html\" class=\"preview__body--description--blue\" target=\"_blank\">downloads page</a> (the\nversion number is configurable via the <code>--version</code> argument), and extract the <code>nomad</code> binary into\n<code>/opt/nomad/bin</code>. Add a symlink to the <code>nomad</code> binary in <code>/usr/local/bin</code>.</li>\n<li><code>run-nomad</code>: Copy the <a href=\"/repos/v0.5.2/terraform-aws-nomad/modules/run-nomad\" class=\"preview__body--description--blue\">run-nomad script</a> into <code>/opt/nomad/bin</code>.</li>\n</ul>\n<h3 class=\"preview__body--subtitle\" id=\"install-supervisord\">Install supervisord</h3>\n<p>Install <a href=\"http://supervisord.org/\" class=\"preview__body--description--blue\" target=\"_blank\">supervisord</a>. We use it as a cross-platform supervisor to ensure Nomad is started\nwhenever the system boots and restarted if the Nomad process crashes.</p>\n<h3 class=\"preview__body--subtitle\" id=\"follow-up-tasks\">Follow-up tasks</h3>\n<p>After the <code>install-nomad</code> script finishes running, you may wish to do the following:</p>\n<ol>\n<li>If you have custom Nomad config (<code>.hcl</code>) files, you may want to copy them into the config directory (default:\n<code>/opt/nomad/config</code>).</li>\n<li>If <code>/usr/local/bin</code> isn't already part of <code>PATH</code>, you should add it so you can run the <code>nomad</code> command without\nspecifying the full path.</li>\n</ol>\n<h2 class=\"preview__body--subtitle\" id=\"why-use-git-to-install-this-code\">Why use Git to install this code?</h2>\n<p></p>\n<p>We needed an easy way to install these scripts that satisfied a number of requirements, including working on a variety\nof operating systems and supported versioning. Our current solution is to use <code>git</code>, but this may change in the future.\nSee <a href=\"/repos/terraform-aws-consul/_docs/package-managers.md\" class=\"preview__body--description--blue\">Package Managers</a> for\na full discussion of the requirements, trade-offs, and why we picked <code>git</code>.</p>\n","repoName":"terraform-aws-nomad","repoRef":"v0.5.1","serviceDescriptor":{"serviceName":"HashiCorp Nomad","serviceRepoName":"terraform-aws-nomad","serviceRepoOrg":"hashicorp","cloudProviders":["aws"],"description":"Deploy a Nomad cluster. Supports automatic bootstrapping, discovery of Consul servers, automatic recovery of failed servers.","imageUrl":"nomad.png","licenseType":"open-source","technologies":["Terraform","Bash"],"compliance":[],"tags":[""]},"serviceCategoryName":"Docker orchestration","fileName":"README.md","filePath":"/modules/install-nomad","title":"Repo Browser: HashiCorp Nomad","description":"Browse the repos in the Gruntwork Infrastructure as Code Library."}