Terraform to setup a consul cluster interacting with a nomad cluster
Last updated Feb 16, 2026
46
Stars
12
Forks
0
Issues
0
Stars/day
Attention Score
11
Language breakdown
No language data available.
▸ Files
click to expand
README
Hashistack Digitalocean
Terraform to setup a consul and nomad cluster by building the number of servers and clients specified. It wraps them around a firewall that can only be accesses via a bastion host (ssh) and a load balancer (http) Uses digital ocean as a provider to create the droplets needed. Sets up Vault to store secretsNow also uses Consul Connect as a sidecar allocation to interact with other services
It starts nomad and consul as a service and automatically connects all nodes in the cluster
Environment variables
do_token- api token for digital ocean which can be found in your DigitalOcean Account under "API"ssh_fingerprint- the ssh fingerprint to use to connect to your newly created dropletsbastionhostid- the droplet id of the bastion host serverserver_count- number of server droplets to createclient_count- number of client droplets to create
Modules
server-droplet
- Create servers and sets up nomad and consul in server mode
server_count- number of server droplets to create
client-droplet
- Create clients and sets up nomad and consul in client mode
client_count- number of client droplets to createconsulserverip- a consul server ip
load-balancer
- Create a public load balancer to connect to all servers
allserverids- ids of all servers (droplets)
firewall
- Create a firewall around the server and client droplets
allserverids- ids of all servers (droplets)loadbalancerid- the id of the digital ocean load balancerbastion_id- the droplet id of the bastion host
Scripts
Scripts for installing required software in newly created dropletsconsul
installconsul.sh client|server ${self.ipv4addressprivate} ${var.consulserver_ip}
- Installs required software - unzip and docker
- Sets up iptables to allow access to localhost from docker
- Downloads consul and copies the binary to the /user/bin directory
- Starts consul as a service in either server or client mode
- If in client mode, it joins the client to the cluster
nomad
install_nomad.sh client|server
- Downloads nomad and copies the binary to the /user/bin directory
- Starts nomad as a service in either server or client mode
vault
install_vault.sh server
- Downloads vault and copies the binary to the /user/bin directory
- Starts vault as a service in server mode
- Initializes Vault
- Unseals vaults to make it ready for use
- Exports the vault token for nomad to use
How to run
- `
evalssh-agent -s - ssh-add ~/.ssh/idrsa
(add your private key to the ssh agent which corresponds to the sshfingerprint) - terraform init
- terraform plan
- terraform apply`
🔗 More in this category