diff --git a/group_vars/matrix_servers b/group_vars/matrix_servers index 7031927ee..45b5625b3 100755 --- a/group_vars/matrix_servers +++ b/group_vars/matrix_servers @@ -21,6 +21,8 @@ matrix_playbook_docker_installation_enabled: true matrix_playbook_docker_installation_daemon_options: "{{ matrix_playbook_docker_installation_daemon_options_auto | combine(matrix_playbook_docker_installation_daemon_options_custom, recursive=True) }}" +matrix_playbook_docker_installation_daemon_options_file_path: /etc/docker/daemon.json + # Since Docker 27.0.1, Docker daemon options do not need to be changed to enable IPv6 support on the daemon side. # See: https://docs.docker.com/engine/release-notes/27/#ipv6 # We only enable `ip6tables` and `experimental` for people who explicitly request it (perhaps due to running an old Docker version). diff --git a/roles/custom/matrix_playbook_migration/tasks/docker_daemon_options_file_cleanup.yml b/roles/custom/matrix_playbook_migration/tasks/docker_daemon_options_file_cleanup.yml new file mode 100644 index 000000000..9018d4a29 --- /dev/null +++ b/roles/custom/matrix_playbook_migration/tasks/docker_daemon_options_file_cleanup.yml @@ -0,0 +1,20 @@ +--- + +# ansible-role-docker creates the Docker daemon options file (`/etc/docker/daemon.json`) when options are set +# via `matrix_playbook_docker_installation_daemon_options` (which influences the `docker_daemon_options` variable of the role). +# See: https://github.com/geerlingguy/ansible-role-docker/blob/acade8d01f11bcd5efecba6d8211138d7567ce4b/tasks/main.yml#L53-L66 +# +# However, it doesn't delete the file when the options list is empty. +# +# This means that people who previously force-disabled IPv6 (and injected `{'ipv6': false}` options, etc) +# or had some other custom options had that file created for them. +# Later, when they stopped setting these options, they were stuck with the configuration file that still retained them. +# +# Here, we make the file go away of no options are set. +# Idealy, this task would be part of the `ansible-role-docker` role, but it's not (yet). +- name: Ensure the Docker daemon options file is deleted when no longer needed + when: matrix_playbook_docker_installation_daemon_options.keys() | length == 0 + ansible.builtin.file: + path: "{{ matrix_playbook_docker_installation_daemon_options_file_path }}" + state: absent + notify: restart docker diff --git a/roles/custom/matrix_playbook_migration/tasks/main.yml b/roles/custom/matrix_playbook_migration/tasks/main.yml index c11dbcb5b..a4ccb8e3c 100644 --- a/roles/custom/matrix_playbook_migration/tasks/main.yml +++ b/roles/custom/matrix_playbook_migration/tasks/main.yml @@ -28,6 +28,15 @@ block: - ansible.builtin.include_tasks: "{{ role_path }}/tasks/debian_docker_trusted_gpg_d_migration_migration.yml" +- when: matrix_playbook_docker_installation_enabled | bool + tags: + - setup-all + - install-all + - setup-docker + - install-docker + block: + - ansible.builtin.include_tasks: "{{ role_path }}/tasks/docker_daemon_options_file_cleanup.yml" + - tags: - setup-all - install-all