This commit is contained in:
martin.fencl
2026-02-03 19:18:25 +01:00
parent 6d580e80b0
commit b24135352c

View File

@@ -11,7 +11,10 @@
tasks:
- name: Check if agent container exists
ansible.builtin.command:
argv: ["bash", "-lc", "docker ps -a --format '{{.Names}}' | grep -x '{{ agent_container_name }}'"]
argv:
- bash
- -lc
- "docker ps -a --format '{{ \"{{\" }}.Names{{ \"}}\" }}' | grep -x '{{ agent_container_name }}'"
register: agent_exists
changed_when: false
failed_when: false
@@ -23,13 +26,19 @@
- name: Read current agent image
ansible.builtin.command:
argv: ["bash", "-lc", "docker inspect -f '{{.Config.Image}}' {{ agent_container_name }}"]
argv:
- bash
- -lc
- "docker inspect -f '{{ \"{{\" }}.Config.Image{{ \"}}\" }}' {{ agent_container_name }}"
register: agent_image
changed_when: false
- name: Pull latest image tag for current agent image
ansible.builtin.command:
argv: ["bash", "-lc", "docker pull {{ agent_image.stdout | trim }}"]
argv:
- bash
- -lc
- "docker pull {{ agent_image.stdout | trim }}"
changed_when: true
- name: Recreate agent container with standard Portainer Agent args