Skip to content

Ricardo fixing nomad license #22

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jul 1, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 20 additions & 11 deletions modules/templates/server/nomad.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,15 @@ echo "--> Fetching enterprise binaries"
install_from_url "nomad" "${nomad_ent_url}"
fi

echo "--> Waiting for Vault leader"
while ! host active.vault.service.consul &> /dev/null; do
sleep 5
done

echo "--> Generating Vault token..."
export VAULT_TOKEN="$(consul kv get service/vault/root-token)"
NOMAD_VAULT_TOKEN="$(VAULT_TOKEN="$VAULT_TOKEN" \
VAULT_ADDR="https://vault.query.consul:8200" \
export NOMAD_VAULT_TOKEN="$(VAULT_TOKEN="$VAULT_TOKEN" \
VAULT_ADDR="https://active.vault.service.consul:8200" \
VAULT_SKIP_VERIFY=true \
vault token create -field=token -policy=superuser -policy=nomad-server -display-name=${node_name} -id=${node_name} -period=72h)"

Expand Down Expand Up @@ -145,24 +150,28 @@ EOF

sudo systemctl enable nomad
sudo systemctl start nomad
sleep 2
sleep 5

echo "--> Waiting for all Nomad servers"
while [ "$(nomad server members 2>&1 | grep "alive" | wc -l)" -lt "${nomad_servers}" ]; do
sleep 5
echo "--> Waiting for Nomad leader"
while ! curl -s -k https://localhost:4646/v1/status/leader --show-error; do
sleep 2
done

echo "--> Waiting for Nomad leader"
while [ -z "$(curl -s http://localhost:4646/v1/status/leader)" ]; do
sleep 5
echo "--> Waiting for a list of Nomad peers"
while ! curl -s -k https://localhost:4646/v1/status/peers --show-error; do
sleep 2
done

echo "--> Waiting for all Nomad servers"
while [ "$(nomad server members 2>&1 | grep "alive" | wc -l)" -lt "${nomad_servers}" ]; do
sleep 5
done

if [ ${enterprise} == 1 ]
then
echo "--> apply Nomad License"
sudo nomad license put "${nomadlicense}" > /tmp/nomadlicense.out

echo -n "${nomadlicense}" > /tmp/nomad.hclic
nomad license put /tmp/nomad.hclic > /tmp/nomadlicense.out

fi

Expand Down
3 changes: 1 addition & 2 deletions modules/templates/workers/nomad.sh
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ while ! host active.vault.service.consul &> /dev/null; do
done

echo "--> Waiting for Nomad leader"
while [ -z "$(curl -s http://localhost:4646/v1/status/leader)" ]; do
while [ -z "$(curl -s https://localhost:4646/v1/status/leader)" ]; do
sleep 5
done

Expand All @@ -170,4 +170,3 @@ echo "--> Running Nomad Job"
fi

echo "==> Run Nomad is Done!"