---
- name: Fix Nomad server configuration
  hosts: localhost
  gather_facts: no
  become: yes
  tasks:
    - name: Create corrected nomad.hcl
      copy:
        dest: /etc/nomad.d/nomad.hcl
        content: |
          datacenter = "dc1"
          data_dir = "/opt/nomad/data"
          log_level = "INFO"

          bind_addr = "100.116.158.95"

          server {
            enabled = true
            bootstrap_expect = 5
            encrypt = "NVOMDvXblgWfhtzFzOUIHnKEOrbXOkPrkIPbRGGf1YQ="
            retry_join = [
              "100.116.158.95", # semaphore
              "100.81.26.3",    # ash1d
              "100.103.147.94", # ash2e
              "100.90.159.68",  # ch2
              "100.86.141.112"  # ch3
            ]
          }

          client {
            enabled = false
          }

          plugin "podman" {
            config {
              socket_path = "unix:///run/podman/podman.sock"
              volumes {
                enabled = true
              }
            }
          }

          consul {
            address = "100.116.158.95:8500"
          }