- name: Install required system packages by apt
  block:
    - name: Install SSL tools
      apt:
        package:
          - apt-transport-https
          - gnupg-agent
          - software-properties-common
        update_cache: yes
        state: latest

    - name: Add key for docker repository
      apt_key:
        url: https://download.docker.com/linux/{{ ansible_distribution | lower }}/gpg
        state: present

    - name: Add docker repository
      apt_repository:
        repo: deb [arch=amd64] https://download.docker.com/linux/{{ ansible_distribution | lower }} {{ ansible_distribution_release }} stable
        state: present
        update_cache: yes

    - name: Install Docker
      apt:
        package:
        - docker-ce
        - docker-ce-cli
        - containerd.io
        state: present

