geerlingguy.ansible-role-do.../tasks
Slavi Pantaleev 5a2fd928ad
Ensure the Docker daemon options file (/etc/docker/daemon.json) is deleted when no longer needed
If people set options in `docker_daemon_options` (e.g. `{'ipv6': false}`), the role will create the `/etc/docker/daemon.json` file and populate it with the options.

Later on, if people stop setting *all of these* options, the file used to remain in place (containing the old options) and cause trouble. This is unexpected.

If the Docker installation is managed by this role and the `/etc/docker/daemon.json` file is managed by it, it should also take care to:

- either delete the file when it's no longer necessary
- or populate it with empty options if that is what `docker_daemon_options` contains

Deleting the file instead of putting `{}` in it seems like the cleaner approach.

There's a chance that people would like to manage options in `/etc/docker/daemon.json` by themselves (without Ansible) and this new behavior when `docker_daemon_options` is empty, but this runs against having a managed Docker installation via Ansible.

This patch only deletes the `/etc/docker/daemon.json` file.

We could possibly delete the `/etc/docker` directory too, but it's more tricky to delete it only when it's empty. In some cases, the directory may contain other files and invoking the `file` module with `state: absent` will delete everything recursively, which is undesirable.
2025-03-09 16:20:51 +02:00
..
docker-compose.yml
docker-users.yml
main.yml Ensure the Docker daemon options file (/etc/docker/daemon.json) is deleted when no longer needed 2025-03-09 16:20:51 +02:00
setup-Debian.yml fix: issue with #470 fix 2025-02-06 21:09:29 +00:00
setup-RedHat.yml update: docker_obsolete_packages separated for Debian and RedHat OS-Family 2025-02-17 01:21:15 +03:30