28 lines
807 B
YAML
28 lines
807 B
YAML
# command: ansible-playbook -i config/<target manifest>.ini common/update-docker.yml
|
|
---
|
|
- name: Update Docker only on hosts where it is installed
|
|
hosts: all
|
|
become: true
|
|
become_method: sudo
|
|
|
|
tasks:
|
|
- name: Check if Docker is installed
|
|
ansible.builtin.command: docker --version
|
|
register: docker_check
|
|
ignore_errors: true
|
|
changed_when: false
|
|
|
|
- name: Update Docker packages if installed
|
|
ansible.builtin.apt:
|
|
name:
|
|
- docker-ce
|
|
- docker-ce-cli
|
|
- containerd.io
|
|
state: latest
|
|
update_cache: yes
|
|
when: docker_check.rc == 0
|
|
|
|
- name: Debug message if Docker is not installed
|
|
ansible.builtin.debug:
|
|
msg: "Docker is not installed on this host. Skipping update."
|
|
when: docker_check.rc != 0 |