Skip to content

Commit a12cf66

Browse files
authored
Merge pull request #22 from GuyBarros/ricardo-fixing-nomad-license
Ricardo fixing nomad license
2 parents 62c0705 + 3c7eada commit a12cf66

File tree

2 files changed

+21
-13
lines changed

2 files changed

+21
-13
lines changed

modules/templates/server/nomad.sh

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,15 @@ echo "--> Fetching enterprise binaries"
99
install_from_url "nomad" "${nomad_ent_url}"
1010
fi
1111

12+
echo "--> Waiting for Vault leader"
13+
while ! host active.vault.service.consul &> /dev/null; do
14+
sleep 5
15+
done
16+
1217
echo "--> Generating Vault token..."
1318
export VAULT_TOKEN="$(consul kv get service/vault/root-token)"
14-
NOMAD_VAULT_TOKEN="$(VAULT_TOKEN="$VAULT_TOKEN" \
15-
VAULT_ADDR="https://vault.query.consul:8200" \
19+
export NOMAD_VAULT_TOKEN="$(VAULT_TOKEN="$VAULT_TOKEN" \
20+
VAULT_ADDR="https://active.vault.service.consul:8200" \
1621
VAULT_SKIP_VERIFY=true \
1722
vault token create -field=token -policy=superuser -policy=nomad-server -display-name=${node_name} -id=${node_name} -period=72h)"
1823

@@ -145,24 +150,28 @@ EOF
145150

146151
sudo systemctl enable nomad
147152
sudo systemctl start nomad
148-
sleep 2
153+
sleep 5
149154

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

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

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

161170
if [ ${enterprise} == 1 ]
162171
then
163172
echo "--> apply Nomad License"
164-
sudo nomad license put "${nomadlicense}" > /tmp/nomadlicense.out
165-
173+
echo -n "${nomadlicense}" > /tmp/nomad.hclic
174+
nomad license put /tmp/nomad.hclic > /tmp/nomadlicense.out
166175

167176
fi
168177

modules/templates/workers/nomad.sh

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ while ! host active.vault.service.consul &> /dev/null; do
155155
done
156156

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

@@ -170,4 +170,3 @@ echo "--> Running Nomad Job"
170170
fi
171171

172172
echo "==> Run Nomad is Done!"
173-

0 commit comments

Comments
 (0)