Update Portainer across release channels
This commit is contained in:
@@ -2,3 +2,4 @@
|
|||||||
# Watchtower is used only as a one-shot updater. It recreates the selected
|
# Watchtower is used only as a one-shot updater. It recreates the selected
|
||||||
# Portainer containers with their existing configuration and then removes itself.
|
# Portainer containers with their existing configuration and then removes itself.
|
||||||
portainer_watchtower_image: containrrr/watchtower:latest
|
portainer_watchtower_image: containrrr/watchtower:latest
|
||||||
|
portainer_target_tag: latest
|
||||||
|
|||||||
@@ -44,12 +44,50 @@
|
|||||||
| map(attribute='item')
|
| map(attribute='item')
|
||||||
| list }}
|
| list }}
|
||||||
|
|
||||||
|
- name: Pull the latest release for each installed Portainer edition
|
||||||
|
ansible.builtin.command:
|
||||||
|
argv:
|
||||||
|
- docker
|
||||||
|
- image
|
||||||
|
- pull
|
||||||
|
- >-
|
||||||
|
{{ 'portainer/portainer-ee:' ~ portainer_target_tag
|
||||||
|
if 'portainer-ee' in item.stdout
|
||||||
|
else 'portainer/portainer-ce:' ~ portainer_target_tag }}
|
||||||
|
loop: "{{ portainer_container_inspections.results }}"
|
||||||
|
loop_control:
|
||||||
|
label: "{{ item.stdout }}"
|
||||||
|
register: portainer_image_pulls
|
||||||
|
changed_when: "'Downloaded newer image' in portainer_image_pulls.stdout"
|
||||||
|
when:
|
||||||
|
- item.stdout is match('^(?:[^/]+/)?portainer/(?:portainer|portainer-(?:ce|ee))(?::|@|$)')
|
||||||
|
- not ansible_check_mode
|
||||||
|
|
||||||
|
- name: Point the existing image reference at the latest release
|
||||||
|
ansible.builtin.command:
|
||||||
|
argv:
|
||||||
|
- docker
|
||||||
|
- image
|
||||||
|
- tag
|
||||||
|
- >-
|
||||||
|
{{ 'portainer/portainer-ee:' ~ portainer_target_tag
|
||||||
|
if 'portainer-ee' in item.stdout
|
||||||
|
else 'portainer/portainer-ce:' ~ portainer_target_tag }}
|
||||||
|
- "{{ item.stdout }}"
|
||||||
|
loop: "{{ portainer_container_inspections.results }}"
|
||||||
|
loop_control:
|
||||||
|
label: "{{ item.stdout }}"
|
||||||
|
changed_when: false
|
||||||
|
when:
|
||||||
|
- item.stdout is match('^(?:[^/]+/)?portainer/(?:portainer|portainer-(?:ce|ee))(?::|$)')
|
||||||
|
- not ansible_check_mode
|
||||||
|
|
||||||
- name: Update discovered Portainer containers
|
- name: Update discovered Portainer containers
|
||||||
ansible.builtin.command:
|
ansible.builtin.command:
|
||||||
argv: >-
|
argv: >-
|
||||||
{{ ['docker', 'run', '--rm', '--pull', 'always',
|
{{ ['docker', 'run', '--rm', '--pull', 'always',
|
||||||
'--volume', '/var/run/docker.sock:/var/run/docker.sock',
|
'--volume', '/var/run/docker.sock:/var/run/docker.sock',
|
||||||
portainer_watchtower_image, '--run-once', '--cleanup',
|
portainer_watchtower_image, '--run-once', '--cleanup', '--no-pull',
|
||||||
'--include-stopped']
|
'--include-stopped']
|
||||||
+ portainer_container_ids }}
|
+ portainer_container_ids }}
|
||||||
register: portainer_watchtower
|
register: portainer_watchtower
|
||||||
|
|||||||
Reference in New Issue
Block a user