---
- name: Install Docker repository
  become: true
  ansible.builtin.get_url:
    url: https://download.docker.com/linux/centos/docker-ce.repo
    dest: /etc/yum.repos.d/docker-ce.repo
    owner: root
    group: "{{ ansible_user }}"
    mode: 0644
  register: _docker_repo_status

- name: Install docker repository GPG key
  become: true
  ansible.builtin.rpm_key:
    key: https://download.docker.com/linux/centos/gpg
    state: present

- name: Install Docker
  become: true
  ansible.builtin.dnf:
    state: present
    name:
      - docker-ce
      - docker-ce-cli
      - containerd.io
    update_cache: "{{ _docker_repo_status.changed }}"
