---
- name: Install docker
  hosts: ulna

  tasks:
  - name: Setup
    ansible.builtin.command: dpkg --print-architecture
    register: architecture

  - name: Add Docker GPG key
    become: true
    ansible.builtin.shell: wget -O- https://download.docker.com/linux/debian/gpg | gpg --dearmor | sudo tee /etc/apt/trusted.gpg.d/docker.gpg

  - name: Add Docker repository
    become: true
    ansible.builtin.apt_repository:
      repo: "deb [arch=\"{{ architecture.stdout_lines[0] }}\" signed-by=/etc/apt/trusted.gpg.d/docker.gpg] https://download.docker.com/linux/debian {{ ansible_distribution_release }} stable"
      state: present

  - name: Install docker
    become: true
    ansible.builtin.apt:
      pkg:
      - docker-ce
      - docker-ce-cli
      - containerd.io
      - docker-compose
      state: latest
      update_cache: true
