---
- name: Ensure old versions of Docker are not installed. | Debian
  package:
    name: '{{ item }}'
    state: absent
  with_items:
    - docker
    - docker-engine
  when: ansible_os_family == 'Debian' and (docker_versioned_pkg[docker_version | string] | search('docker-ce'))

- name: Ensure old versions of Docker are not installed. | RedHat
  package:
    name: '{{ item }}'
    state: absent
  with_items:
    - docker
    - docker-common
    - docker-engine
    - docker-selinux
  when: ansible_os_family == 'RedHat' and (docker_versioned_pkg[docker_version | string] | search('docker-ce'))