---
- name: Manually run Nomad agent for debugging
  hosts: germany
  become: yes
  tasks:
    - name: Find Nomad binary path
      shell: which nomad || find /usr -name nomad 2>/dev/null | head -1
      register: nomad_binary_path
      failed_when: nomad_binary_path.stdout == ""

    - name: Run nomad agent directly
      command: "{{ nomad_binary_path.stdout }} agent -config=/etc/nomad.d/nomad.hcl"
      register: nomad_run
      failed_when: false

    - name: Display Nomad output
      debug:
        var: nomad_run.stdout

    - name: Display Nomad error output
      debug:
        var: nomad_run.stderr