--- - name: Fix Nomad Cluster Issues hosts: nomad_cluster become: yes vars: nomad_encrypt_key: "NVOMDvXblgWfhtzFzOUIHnKEOrbXOkPrkIPbRGGf1YQ=" tasks: - name: Stop nomad service systemd: name: nomad state: stopped ignore_errors: yes - name: Clean nomad data directory shell: rm -rf /opt/nomad/data/* ignore_errors: yes - name: Create correct nomad configuration copy: content: | datacenter = "dc1" region = "global" data_dir = "/opt/nomad/data" bind_addr = "{{ ansible_host | default(hostvars[inventory_hostname]['ansible_default_ipv4']['address']) }}" server { enabled = true bootstrap_expect = 3 encrypt = "{{ nomad_encrypt_key }}" server_join { retry_join = ["100.116.158.95", "100.117.106.136", "100.116.80.94"] } } client { enabled = true network_interface = "{{ ansible_default_ipv4.interface | default('eth0') }}" } ui { enabled = true } addresses { http = "0.0.0.0" rpc = "0.0.0.0" serf = "0.0.0.0" } ports { http = 4646 rpc = 4647 serf = 4648 } plugin "docker" { config { allow_privileged = true volumes { enabled = true } } } dest: /etc/nomad.d/nomad.hcl owner: nomad group: nomad mode: '0640' - name: Start nomad service systemd: name: nomad state: started enabled: yes - name: Wait for nomad to start wait_for: port: 4646 host: "{{ ansible_host | default(hostvars[inventory_hostname]['ansible_default_ipv4']['address']) }}" delay: 10 timeout: 60 - name: Check nomad status shell: systemctl status nomad --no-pager -l register: nomad_status ignore_errors: yes - name: Display nomad status debug: var: nomad_status.stdout_lines