--- - name: uninstall old docker versions package: name: ['docker', 'docker-engine', 'docker.io', 'containerd', 'runc'] state: absent - name: allow apt to use a repository over https (debian) package: name: ['apt-transport-https', 'ca-certificates', 'software-properties-common'] update_cache: yes register: result until: result is succeeded - name: add docker's gpg key apt_key: url: 'https://download.docker.com/linux/{{ ansible_distribution | lower }}/gpg' register: result until: result is succeeded - name: add docker repository apt_repository: repo: "deb https://download.docker.com/linux/{{ ansible_distribution | lower}} {{ ansible_distribution_release }} stable"