- name: Install aptitude
  apt:
    name: aptitude
    state: latest
    update_cache: true
  become: true

- name: Install required system packages
  apt:
    pkg:
      - apt-transport-https
      - ca-certificates
      - curl
      - software-properties-common
      - python3-pip
      - virtualenv
      - python3-setuptools
    state: latest
    update_cache: true
  become: true

- name: Add Docker GPG apt Key
  apt_key:
    url: https://download.docker.com/linux/ubuntu/gpg
    state: present
  become: true

- name: Add Docker Repository
  apt_repository:
    repo: deb https://download.docker.com/linux/ubuntu focal stable
    state: present
  become: true

- name: Update apt and install docker packages
  apt:
    pkg:
      - docker-ce
      - docker-ce-cli
      - containerd.io
      - docker-buildx-plugin
      - docker-compose-plugin
    state: latest
    update_cache: true
  become: true

- name: Add user to the Docker group
  user:
    name: "{{ ansible_user }}"
    groups: docker
    append: yes
  become: true

- name: Create a network
  community.docker.docker_network:
    name: apps