aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/roles/docker
diff options
context:
space:
mode:
authorEgor Tensin <egor@tensin.name>2026-10-23 05:18:14 +0300
committerEgor Tensin <egor@tensin.name>2026-10-23 05:32:45 +0300
commit0f0c60ac4453156834c2f538c820bc175bc3f443 (patch)
tree102a629721b788f89c9fd5c85fb9d02b5b9b471a /roles/docker
parentdocker: try another workaround for fresh installs (diff)
downloadinfra-ansible-0f0c60ac4453156834c2f538c820bc175bc3f443.tar.gz
infra-ansible-0f0c60ac4453156834c2f538c820bc175bc3f443.zip
docker: yet another attempt to fix new installations
Diffstat (limited to 'roles/docker')
-rw-r--r--roles/docker/tasks/prune.yml25
1 files changed, 9 insertions, 16 deletions
diff --git a/roles/docker/tasks/prune.yml b/roles/docker/tasks/prune.yml
index 3167ee6..e6f1f5d 100644
--- a/roles/docker/tasks/prune.yml
+++ b/roles/docker/tasks/prune.yml
@@ -1,29 +1,22 @@
-# Temporarily disable the services; systemd_info below uses systemctl list-units,
-# and it doesn't seem to update its info right after installation (so, list-units
-# doesn't show the Docker units); hopefully, disabling them will make them
-# appear in list-units output, idk.
-- name: Disable Docker services
- become: true
- ansible.builtin.systemd_service:
- name: '{{ item }}'
- enabled: false
- loop:
- - docker.service
- - docker.socket
-
- name: Collect service facts
community.general.systemd_info:
unitname:
- docker.service
- docker.socket
register: docker_systemd_info
+ failed_when:
+ docker_systemd_info.msg is defined
+ and "No units match any of the provided patterns" not in docker_systemd_info.msg
+# ^^^ On fresh installations, systemctl list-units (which is what systemd_info
+# does, it doesn't show the Docker units at all, don't exactly understand why.
- name: Clean up docker data
become: true
when: |
- docker_systemd_info.units['docker.service'].substate == 'running'
- or docker_systemd_info.units['docker.socket'].substate == 'listening'
- or docker_systemd_info.units['docker.socket'].substate == 'running'
+ docker_systemd_info.units is defined
+ and (docker_systemd_info.units['docker.service'].substate == 'running'
+ or docker_systemd_info.units['docker.socket'].substate == 'listening'
+ or docker_systemd_info.units['docker.socket'].substate == 'running')
block:
# Dependencies of the community.docker.docker_prune Ansible module:
- name: Install module dependencies