--- - name: Install aptitude ansible.builtin.apt: name: aptitude state: latest update_cache: true - name: Install required packages ansible.builtin.apt: pkg: - apt-transport-https - ca-certificates - curl - software-properties-common - python3-pip - virtualenv - python3-setuptools state: latest update_cache: true - name: Add Docker GPG apt Key ansible.builtin.apt_key: url: https://download.docker.com/linux/ubuntu/gpg state: present - name: Add Docker Repository ansible.builtin.apt_repository: repo: deb https://download.docker.com/linux/ubuntu focal stable state: present - name: Update apt and install docker-ce ansible.builtin.apt: name: docker-ce state: latest update_cache: true - name: Run default container to test Docker install community.docker.docker_container: name: test_container image: hello-world state: present - name: Add users to Docker group (allows running Docker commands without sudo) ansible.builtin.user: name: "{{ item.key }}" groups: "sudo, docker" loop: "{{ lookup('dict', users) }}"