Rami Dridi
Rami Dridi

Reputation: 351

can't open nomad ui after vagrant up

I'm trying to setup nomad using vagrant it works and I've being able to connect to vm using ssh and start nomad using :

nomad agent -dev

==> Nomad agent configuration:

       Advertise Addrs: HTTP: 127.0.0.1:4646; RPC: 127.0.0.1:4647; Serf: 127.0.0.1:4648
            Bind Addrs: HTTP: [127.0.0.1:4646]; RPC: 127.0.0.1:4647; Serf: 127.0.0.1:4648
                Client: true
             Log Level: DEBUG
                Region: global (DC: dc1)
                Server: true
               Version: 1.3.1

==> Nomad agent started! Log data will stream in below:

    2025-02-08T00:14:51.959Z [DEBUG] agent.plugin_loader.docker: using client connection initialized from environment: plugin_dir=""
    2025-02-08T00:14:51.959Z [DEBUG] agent.plugin_loader.docker: using client connection initialized from environment: plugin_dir=""
    2025-02-08T00:14:51.960Z [INFO]  agent: detected plugin: name=java type=driver plugin_version=0.1.0
    2025-02-08T00:14:51.960Z [INFO]  agent: detected plugin: name=docker type=driver plugin_version=0.1.0

but when I hit localhost:4646 it doesn't work (no signal)


 $ curl localhost:4646
 curl: (56) Recv failure: Connection reset by peer

I've checked forward ports and they are correct. this is my vagrant config file :

# -*- mode: ruby -*-
# vi: set ft=ruby :

$script = <<SCRIPT
echo "Installing Docker..."
sudo apt-get update
sudo apt-get remove docker docker-engine docker.io
echo '* libraries/restart-without-asking boolean true' | sudo debconf-set-selections
sudo apt-get install apt-transport-https ca-certificates curl software-properties-common -y
sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg |  sudo apt-key add -
sudo apt-key fingerprint 0EBFCD88
sudo add-apt-repository \
      "deb [arch=amd64] https://download.docker.com/linux/ubuntu \
      $(lsb_release -cs) \
      stable"
sudo apt-get update
sudo apt-get install -y docker-ce
# Restart docker to make sure we get the latest version of the daemon if there is an upgrade
sudo service docker restart
# Make sure we can actually use docker as the vagrant user
sudo usermod -aG docker vagrant
sudo docker --version

# Packages required for nomad & consul
sudo apt-get install unzip curl vim -y

echo "Installing Nomad..."
NOMAD_VERSION=1.3.1
cd /tmp/
curl -sSL https://releases.hashicorp.com/nomad/${NOMAD_VERSION}/nomad_${NOMAD_VERSION}_linux_amd64.zip -o nomad.zip
unzip nomad.zip
sudo install nomad /usr/bin/nomad
sudo mkdir -p /etc/nomad.d
sudo chmod a+w /etc/nomad.d


echo "Installing Consul..."
CONSUL_VERSION=1.12.2
curl -sSL https://releases.hashicorp.com/consul/${CONSUL_VERSION}/consul_${CONSUL_VERSION}_linux_amd64.zip > consul.zip
unzip /tmp/consul.zip
sudo install consul /usr/bin/consul
(
cat <<-EOF
  [Unit]
  Description=consul agent
  Requires=network-online.target
  After=network-online.target

  [Service]
  Restart=on-failure
  ExecStart=/usr/bin/consul agent -dev
  ExecReload=/bin/kill -HUP $MAINPID

  [Install]
  WantedBy=multi-user.target
EOF
) | sudo tee /etc/systemd/system/consul.service
sudo systemctl enable consul.service
sudo systemctl start consul

for bin in cfssl cfssl-certinfo cfssljson
do
  echo "Installing $bin..."
  curl -sSL https://pkg.cfssl.org/R1.2/${bin}_linux-amd64 > /tmp/${bin}
  sudo install /tmp/${bin} /usr/local/bin/${bin}
done
nomad -autocomplete-install

SCRIPT

Vagrant.configure(2) do |config|
  config.vm.box = "bento/ubuntu-22.04" # 22.04 LTS, Jammy
  config.vm.hostname = "nomad"
  config.vm.provision "shell", inline: $script, privileged: false

  # Expose the nomad api and ui to the host
  config.vm.network "forwarded_port", guest: 4646, host: 4646, auto_correct: true, host_ip: "0.0.0.0",protocol: "tcp"
  config.vm.network "forwarded_port", guest: 4646, host: 4645, auto_correct: true, host_ip: "127.0.0.1",protocol: "tcp"

  # Increase memory for Libvirt
  config.vm.provider "libvirt" do |libvirt|
    libvirt.memory = 1024
  end

  # Increase memory for Parallels Desktop
  config.vm.provider "parallels" do |p, o|
    p.memory = "1024"
  end

  # Increase memory for Virtualbox
  config.vm.provider "virtualbox" do |vb|
        vb.memory = "1024"
  end

  # Increase memory for VMware
  ["vmware_fusion", "vmware_workstation"].each do |p|
    config.vm.provider p do |v|
      v.vmx["memsize"] = "1024"
    end
  end
end

I'm expecting the ui to be available in my browser

I've tried binding to another port but it's not working too.

EDIT : when I execute systemctl status inside vm :

vagrant@nomad:~$ sudo systemctl status 
● nomad
    State: degraded
     Jobs: 0 queued
   Failed: 1 units
    Since: Sat 2025-02-08 00:12:12 UTC; 23min ago
   CGroup: /
           ├─user.slice 
           │ └─user-1000.slice 
           │   ├─[email protected] …
           │   │ └─init.scope 
           │   │   ├─2163 /lib/systemd/systemd --user
           │   │   └─2164 (sd-pam)
           │   ├─session-6.scope 
           │   │ ├─2222 sshd: vagrant [priv]
           │   │ ├─2243 sshd: vagrant@pts/1
           │   │ ├─2244 -bash
           │   │ ├─2865 sudo systemctl status
           │   │ ├─2866 sudo systemctl status
           │   │ ├─2867 systemctl status
           │   │ └─2868 less
           │   └─session-4.scope 
           │     ├─2160 sshd: vagrant [priv]
           │     ├─2199 sshd: vagrant@pts/0
           │     ├─2200 -bash
           │     └─2209 nomad agent -dev
           ├─init.scope 
           │ └─1 /sbin/init
           └─system.slice 
             ├─irqbalance.service 
             │ └─666 /usr/sbin/irqbalance --foreground
             ├─containerd.service …
             │ └─681 /usr/bin/containerd
             ├─systemd-networkd.service 
             │ └─644 /lib/systemd/systemd-networkd
             ├─systemd-udevd.service 
             │ └─462 /lib/systemd/systemd-udevd
             ├─cron.service 
             │ └─690 /usr/sbin/cron -f -P
             ├─docker.service …
             │ └─1519 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock
             ├─polkit.service 
             │ └─668 /usr/libexec/polkitd --no-debug
             ├─networkd-dispatcher.service 
             │ └─667 /usr/bin/python3 /usr/bin/networkd-dispatcher --run-startup-triggers
             ├─multipathd.service 
             │ └─459 /sbin/multipathd -d -s
             ├─ModemManager.service 
             │ └─799 /usr/sbin/ModemManager
             ├─vboxadd.service 
             │ ├─1142 /usr/bin/VBoxDRMClient
             │ └─1146 /usr/sbin/VBoxService --pidfile /var/run/vboxadd-service.sh
             ├─systemd-journald.service 
             │ └─419 /lib/systemd/systemd-journald
             ├─ssh.service 
             │ └─782 sshd: /usr/sbin/sshd -D [listener] 0 of 10-100 startups
             ├─snapd.service 
             │ └─672 /usr/lib/snapd/snapd
             ├─rsyslog.service 
             │ └─669 /usr/sbin/rsyslogd -n -iNONE
             ├─consul.service 
             │ └─658 /usr/bin/consul agent -dev
             ├─systemd-resolved.service 
             │ └─646 /lib/systemd/systemd-resolved
             ├─udisks2.service 
             │ └─679 /usr/libexec/udisks2/udisksd
             ├─dbus.service 
             │ └─659 @dbus-daemon --system --address=systemd: --nofork --nopidfile --systemd-activation --syslog-on>
             ├─system-getty.slice 
             │ └─[email protected] 
             │   └─695 /sbin/agetty -o -p -- \u --noclear tty1 linux
             └─systemd-logind.service 
               └─678 /lib/systemd/systemd-logind

but when I check only nomad :

vagrant@nomad:~$ sudo systemctl status nomad
Unit nomad.service could not be found.

Upvotes: 0

Views: 40

Answers (1)

Rami Dridi
Rami Dridi

Reputation: 351

Solution to this problem in my case : start nomad with --bind 0.0.0.0 flag :

nomad agent -dev --bind 0.0.0.0

Upvotes: 0

Related Questions