[rootless docker] Maintain idempotency in 'command' routines

This commit is contained in:
John Robbins 2023-04-10 20:20:08 -06:00
parent 5685a017bb
commit 218e162054
2 changed files with 9 additions and 3 deletions

View File

@ -26,12 +26,13 @@
- name: Install rootless docker
become: false
command: /usr/bin/dockerd-rootless-setuptool.sh install
when: rootless_conf.stat.exists == false
- name: Enable and start rootless docker
become: false
systemd:
name: docker
state: started
name: docker.service
state: restarted
enabled: true
scope: user

View File

@ -65,10 +65,15 @@
when: docker_daemon_options.keys() | length > 0
notify: restart docker
- name: Stat for rootless docker
stat:
path: "{{ lookup('env', 'XDG_RUNTIME_DIR') }}/docker.sock"
register: rootless_conf
- name: Uninstall rootless docker
become: false
command: /usr/bin/dockerd-rootless-setuptool.sh uninstall --force
when: docker_rootless == false
when: docker_rootless == false and rootless_conf.stat.exists
- name: Ensure Docker is started and enabled at boot
service: