---
- name: Enable Nomad client role on de node
  hosts: localhost
  gather_facts: no
  tasks:
    - name: Update de node Nomad configuration
      copy:
        dest: /root/mgmt/tmp/de-nomad-updated.hcl
        content: |
          datacenter = "dc1"
          data_dir = "/opt/nomad/data"
          plugin_dir = "/opt/nomad/plugins"
          log_level = "INFO"
          name = "de"
          
          bind_addr = "0.0.0.0"
          
          addresses {
            http = "100.120.225.29"
            rpc  = "100.120.225.29"
            serf = "100.120.225.29"
          }
          
          advertise {
            http = "de.tailnet-68f9.ts.net:4646"
            rpc  = "de.tailnet-68f9.ts.net:4647"
            serf = "de.tailnet-68f9.ts.net:4648"
          }
          
          ports {
            http = 4646
            rpc  = 4647
            serf = 4648
          }
          
          server {
            enabled = true
            bootstrap_expect = 3
            server_join {
              retry_join = [
                "semaphore.tailnet-68f9.ts.net:4648",
                "ash1d.tailnet-68f9.ts.net:4648", 
                "ash2e.tailnet-68f9.ts.net:4648",
                "ch2.tailnet-68f9.ts.net:4648",
                "ch3.tailnet-68f9.ts.net:4648",
                "onecloud1.tailnet-68f9.ts.net:4648",
                "de.tailnet-68f9.ts.net:4648",
                "hcp1.tailnet-68f9.ts.net:4648"
              ]
            }
          }
          
          client {
            enabled = true
            network_interface = "tailscale0"
            servers = [
              "ch3.tailnet-68f9.ts.net:4647",
              "ash1d.tailnet-68f9.ts.net:4647",
              "ash2e.tailnet-68f9.ts.net:4647",
              "ch2.tailnet-68f9.ts.net:4647",
              "hcp1.tailnet-68f9.ts.net:4647",
              "onecloud1.tailnet-68f9.ts.net:4647",
              "de.tailnet-68f9.ts.net:4647",
              "semaphore.tailnet-68f9.ts.net:4647"
            ]
          }
          
          consul {
            enabled = false
            auto_advertise = false
          }
          
          telemetry {
            collection_interval = "1s"
            disable_hostname = false
            prometheus_metrics = true
            publish_allocation_metrics = true
            publish_node_metrics = true
          }



