diff --git a/portainer/update_portainer_agent_vm.yml b/portainer/update_portainer_agent_vm.yml index 81d3f93..16509fd 100644 --- a/portainer/update_portainer_agent_vm.yml +++ b/portainer/update_portainer_agent_vm.yml @@ -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 @@ -57,4 +66,4 @@ ansible.builtin.wait_for: host: 127.0.0.1 port: "{{ agent_port }}" - timeout: 60 \ No newline at end of file + timeout: 60