forked from jakub/ansible
.
This commit is contained in:
@@ -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
|
||||
timeout: 60
|
||||
|
||||
Reference in New Issue
Block a user