Skip to content
This repository was archived by the owner on Jul 4, 2023. It is now read-only.

Commit 7021298

Browse files
author
Riaan Nolan
committed
update nomad provisioner ensure consul is running, and formatting
1 parent 0ad76f6 commit 7021298

File tree

1 file changed

+36
-32
lines changed

1 file changed

+36
-32
lines changed

hashicorp/nomad.sh

+36-32
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,26 @@
22

33
function nomad-install() {
44

5-
# ensure localstack is running
6-
echo -e '\e[38;5;198m'"++++ Ensure Consul is running.."
7-
sudo bash /vagrant/hashicorp/consul.sh
5+
if pgrep -x "consul" >/dev/null
6+
then
7+
echo "Consul is running"
8+
else
9+
echo -e '\e[38;5;198m'"++++ Ensure Consul is running.."
10+
sudo bash /vagrant/hashicorp/consul.sh
11+
fi
812

9-
arch=$(lscpu | grep "Architecture" | awk '{print $NF}')
10-
if [[ $arch == x86_64* ]]; then
13+
arch=$(lscpu | grep "Architecture" | awk '{print $NF}')
14+
if [[ $arch == x86_64* ]]; then
1115
ARCH="amd64"
12-
elif [[ $arch == aarch64 ]]; then
16+
elif [[ $arch == aarch64 ]]; then
1317
ARCH="arm64"
14-
fi
15-
echo -e '\e[38;5;198m'"CPU is $ARCH"
18+
fi
19+
echo -e '\e[38;5;198m'"CPU is $ARCH"
1620

17-
sudo DEBIAN_FRONTEND=noninteractive apt-get --assume-yes install curl unzip jq
18-
yes | sudo docker system prune -a
19-
yes | sudo docker system prune --volumes
20-
mkdir -p /etc/nomad
21+
sudo DEBIAN_FRONTEND=noninteractive apt-get --assume-yes install curl unzip jq
22+
yes | sudo docker system prune -a
23+
yes | sudo docker system prune --volumes
24+
mkdir -p /etc/nomad
2125
cat <<EOF | sudo tee /etc/nomad/server.conf
2226
data_dir = "/var/lib/nomad"
2327
@@ -115,26 +119,26 @@ EOF
115119
nomad server members
116120
nomad node status
117121
fi
118-
cd /vagrant/hashicorp/nomad/jobs;
119-
#nomad plan --address=http://localhost:4646 countdashboard.nomad
120-
#nomad run --address=http://localhost:4646 countdashboard.nomad
121-
#nomad plan --address=http://localhost:4646 countdashboardtest.nomad
122-
#nomad run --address=http://localhost:4646 countdashboardtest.nomad
123-
nomad plan --address=http://localhost:4646 fabio.nomad
124-
nomad run --address=http://localhost:4646 fabio.nomad
125-
nomad plan --address=http://localhost:4646 traefik.nomad
126-
nomad run --address=http://localhost:4646 traefik.nomad
127-
nomad plan --address=http://localhost:4646 traefik-whoami.nomad
128-
nomad run --address=http://localhost:4646 traefik-whoami.nomad
129-
# curl -v -H 'Host: fabio.service.consul' http://${VAGRANT_IP}:9999/
130-
echo -e '\e[38;5;198m'"++++ Nomad http://localhost:4646"
131-
echo -e '\e[38;5;198m'"++++ Nomad Documentation http://localhost:3333/#/hashicorp/README?id=nomad"
132-
echo -e '\e[38;5;198m'"++++ Fabio Dashboard http://localhost:9998"
133-
echo -e '\e[38;5;198m'"++++ Fabio Loadbalancer http://localhost:9998"
134-
echo -e '\e[38;5;198m'"++++ Fabio Documentation http://localhost:3333/#/hashicorp/README?id=fabio-load-balancer-for-nomad"
135-
echo -e '\e[38;5;198m'"++++ Treafik Dashboard http://localhost:8181"
136-
echo -e '\e[38;5;198m'"++++ Traefik Loadbalancer: http://localhost:8080"
137-
echo -e '\e[38;5;198m'"++++ Traefik Documentation: http://localhost:3333/#/hashicorp/README?id=traefik-load-balancer-for-nomad"
122+
cd /vagrant/hashicorp/nomad/jobs;
123+
#nomad plan --address=http://localhost:4646 countdashboard.nomad
124+
#nomad run --address=http://localhost:4646 countdashboard.nomad
125+
#nomad plan --address=http://localhost:4646 countdashboardtest.nomad
126+
#nomad run --address=http://localhost:4646 countdashboardtest.nomad
127+
nomad plan --address=http://localhost:4646 fabio.nomad
128+
nomad run --address=http://localhost:4646 fabio.nomad
129+
nomad plan --address=http://localhost:4646 traefik.nomad
130+
nomad run --address=http://localhost:4646 traefik.nomad
131+
nomad plan --address=http://localhost:4646 traefik-whoami.nomad
132+
nomad run --address=http://localhost:4646 traefik-whoami.nomad
133+
# curl -v -H 'Host: fabio.service.consul' http://${VAGRANT_IP}:9999/
134+
echo -e '\e[38;5;198m'"++++ Nomad http://localhost:4646"
135+
echo -e '\e[38;5;198m'"++++ Nomad Documentation http://localhost:3333/#/hashicorp/README?id=nomad"
136+
echo -e '\e[38;5;198m'"++++ Fabio Dashboard http://localhost:9998"
137+
echo -e '\e[38;5;198m'"++++ Fabio Loadbalancer http://localhost:9998"
138+
echo -e '\e[38;5;198m'"++++ Fabio Documentation http://localhost:3333/#/hashicorp/README?id=fabio-load-balancer-for-nomad"
139+
echo -e '\e[38;5;198m'"++++ Treafik Dashboard http://localhost:8181"
140+
echo -e '\e[38;5;198m'"++++ Traefik Loadbalancer: http://localhost:8080"
141+
echo -e '\e[38;5;198m'"++++ Traefik Documentation: http://localhost:3333/#/hashicorp/README?id=traefik-load-balancer-for-nomad"
138142
}
139143

140144
nomad-install

0 commit comments

Comments
 (0)