|
|
|
@ -19,6 +19,20 @@ if [ "$#" -eq 1 ] && [ "$1" == "-client" ]; then
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# create config dir
|
|
|
|
|
mkdir -p /etc/nomad.d && chmod 700 /etc/nomad.d
|
|
|
|
|
|
|
|
|
|
# write common nomad config
|
|
|
|
|
cat >/etc/nomad.d/nomad.hcl <<EOF
|
|
|
|
|
datacenter = "dc1"
|
|
|
|
|
data_dir = "/opt/nomad"
|
|
|
|
|
EOF
|
|
|
|
|
chmod 640 /etc/nomad.d/nomad.hcl
|
|
|
|
|
chown nomad:nomad /etc/nomad.d/nomad.hcl
|
|
|
|
|
|
|
|
|
|
if [ $nomaduser == "nomad" ]; then
|
|
|
|
|
|
|
|
|
|
# write systemd conf
|
|
|
|
|
cat >/etc/systemd/system/nomad.service <<EOF
|
|
|
|
|
[Unit]
|
|
|
|
@ -27,12 +41,9 @@ Documentation = https://nomadproject.io/docs/
|
|
|
|
|
Wants = network-online.target
|
|
|
|
|
After = network-online.target
|
|
|
|
|
|
|
|
|
|
Wants = consul.service
|
|
|
|
|
After = consul.service
|
|
|
|
|
|
|
|
|
|
[Service]
|
|
|
|
|
User = $nomaduser
|
|
|
|
|
Group = $nomadgroup
|
|
|
|
|
User = root
|
|
|
|
|
Group = root
|
|
|
|
|
ExecReload=/bin/kill -HUP \$MAINPID
|
|
|
|
|
ExecStart=/usr/bin/nomad agent -config /etc/nomad.d
|
|
|
|
|
KillMode=process
|
|
|
|
@ -48,41 +59,32 @@ OOMScoreAdjust=-1000
|
|
|
|
|
WantedBy=multi-user.target
|
|
|
|
|
EOF
|
|
|
|
|
|
|
|
|
|
# create config dir
|
|
|
|
|
mkdir -p /etc/nomad.d && chmod 700 /etc/nomad.d
|
|
|
|
|
|
|
|
|
|
# write common nomad config
|
|
|
|
|
cat >/etc/nomad.d/nomad.hcl <<EOF
|
|
|
|
|
datacenter = "dc1"
|
|
|
|
|
data_dir = "/opt/nomad"
|
|
|
|
|
EOF
|
|
|
|
|
chmod 640 /etc/nomad.d/nomad.hcl
|
|
|
|
|
chown nomad:nomad /etc/nomad.d/nomad.hcl
|
|
|
|
|
|
|
|
|
|
if [ $nomaduser == "nomad" ]; then
|
|
|
|
|
|
|
|
|
|
# write server config
|
|
|
|
|
cat >/etc/nomad.d/server.hcl <<EOF
|
|
|
|
|
server {
|
|
|
|
|
enabled = true
|
|
|
|
|
bootstrap_expect = 1
|
|
|
|
|
}
|
|
|
|
|
ui {
|
|
|
|
|
client {
|
|
|
|
|
enabled = true
|
|
|
|
|
}
|
|
|
|
|
consul {
|
|
|
|
|
address = "127.0.0.1:8500"
|
|
|
|
|
}
|
|
|
|
|
EOF
|
|
|
|
|
chmod 640 /etc/nomad.d/server.hcl
|
|
|
|
|
chown nomad:nomad /etc/nomad.d/server.hcl
|
|
|
|
|
else
|
|
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
|
|
# write client config
|
|
|
|
|
cat >/etc/nomad.d/client.hcl <<EOF
|
|
|
|
|
client {
|
|
|
|
|
enabled = true
|
|
|
|
|
}
|
|
|
|
|
EOF
|
|
|
|
|
chmod 640 /etc/nomad.d/client.hcl
|
|
|
|
|
chown nomad:nomad /etc/nomad.d/client.hcl
|
|
|
|
|
# cat >/etc/nomad.d/client.hcl <<EOF
|
|
|
|
|
#client {
|
|
|
|
|
# enabled = true
|
|
|
|
|
#}
|
|
|
|
|
#EOF
|
|
|
|
|
# chmod 640 /etc/nomad.d/client.hcl
|
|
|
|
|
# chown nomad:nomad /etc/nomad.d/client.hcl
|
|
|
|
|
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|