--- - hosts: webhost remote_user: webadmin become: true tasks: - name: Install docker and docker-compose apt: update_cache: true pkg: - ca-certificates - curl - name: Setup keyring command: cmd: "install -m 0755 -d /etc/apt/keyrings" - name: Download docker gpg key get_url: url: https://download.docker.com/linux/ubuntu/gpg dest: /etc/apt/keyrings/docker.asc - name: Set perms on /etc/apt/keyrings/docker.asc file: dest: /etc/apt/keyrings/docker.asc mode: a+r - name: Ensure docker.lst exists copy: content: '' dest: /etc/apt/sources.list.d/docker.list force: false group: root owner: root mode: 0644 - name: Ensure docker.lst is present for apt lineinfile: line: "deb [arch=amd64 signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu jammy stable\n" dest: /etc/apt/sources.list.d/docker.list state: present - name: install docker packages apt: update_cache: true pkg: - docker-ce - docker-ce-cli - containerd.io - docker-buildx-plugin - docker-compose-plugin