Docker Engine has gone through a lot of changes over the last few years. There is enterprise edition, community edition, Docker Desktop has been re-licensed... lots of changes. There were several times where I needed to fully remove all possible Docker engine installs and start over with a fresh install of the latest Docker-CE. To help, and make the job easy, I ended up using an extremely simply playbook to get the job done.
Here is an example of how to use Ansible to remove Docker Engine from a CentOS/RHEL-based host.
Playbook is below!
--- - name: Playbook to stop and remove all Docker related packages and file from hosts hosts: all gather_facts: false become: yes tasks: - name: Stop the Docker service ignore_errors: yes service: name: docker state: stopped - name: Remove the docker-ee package (enterprise) ignore_errors: yes yum: name: docker-ee state: removed - name: Remove the docker-ce package (community edition) ignore_errors: yes yum: name: docker-ce state: removed - name: Remove the base docker package ignore_errors: yes yum: name: docker state: removed - name: Delete the /var/lib/docker directory ignore_errors: yes file: path: /var/lib/docker state: absent