--- - name: Fix Nomad Podman Driver Configuration hosts: nomadlxc,hcp become: yes vars: nomad_user: nomad tasks: - name: Stop Nomad service systemd: name: nomad state: stopped - name: Install Podman driver plugin if missing block: - name: Check if plugin exists stat: path: /opt/nomad/data/plugins/nomad-driver-podman register: plugin_exists - name: Download and install Podman driver plugin block: - name: Download Nomad Podman driver get_url: url: "https://releases.hashicorp.com/nomad-driver-podman/0.6.1/nomad-driver-podman_0.6.1_linux_amd64.zip" dest: "/tmp/nomad-driver-podman.zip" mode: '0644' - name: Extract Podman driver unarchive: src: "/tmp/nomad-driver-podman.zip" dest: "/tmp" remote_src: yes - name: Install Podman driver copy: src: "/tmp/nomad-driver-podman" dest: "/opt/nomad/data/plugins/nomad-driver-podman" owner: "{{ nomad_user }}" group: "{{ nomad_user }}" mode: '0755' remote_src: yes - name: Clean up temporary files file: path: "{{ item }}" state: absent loop: - "/tmp/nomad-driver-podman.zip" - "/tmp/nomad-driver-podman" when: not plugin_exists.stat.exists - name: Update Nomad configuration with correct plugin name and socket path replace: path: /etc/nomad.d/nomad.hcl regexp: 'plugin "podman" \{' replace: 'plugin "nomad-driver-podman" {' - name: Update socket path to system socket replace: path: /etc/nomad.d/nomad.hcl regexp: 'socket_path = "unix:///run/user/1001/podman/podman.sock"' replace: 'socket_path = "unix:///run/podman/podman.sock"' - name: Add plugin_dir configuration if missing lineinfile: path: /etc/nomad.d/nomad.hcl line: 'plugin_dir = "/opt/nomad/data/plugins"' insertafter: 'data_dir = "/opt/nomad/data"' state: present - name: Ensure Podman socket is enabled and running systemd: name: podman.socket enabled: yes state: started - name: Start Nomad service systemd: name: nomad state: started - name: Wait for Nomad to be ready wait_for: port: 4646 host: localhost delay: 10 timeout: 60 - name: Wait for plugins to load pause: seconds: 20 - name: Check driver status shell: | export NOMAD_ADDR=http://localhost:4646 nomad node status -self | grep -A 10 "Driver Status" register: driver_status failed_when: false - name: Display driver status debug: var: driver_status.stdout_lines - name: Check for Podman driver in logs shell: journalctl -u nomad -n 30 --no-pager | grep -E "(podman|plugin)" | tail -10 register: plugin_logs failed_when: false - name: Display plugin logs debug: var: plugin_logs.stdout_lines