tech-test-infra/ansible/docker/tasks/main.yml

60 lines
1.4 KiB
YAML

---
# https://docs.docker.com/engine/install/debian/
- name: Ensure required packages are installed
apt:
name: [
'ca-certificates',
'curl',
'gnupg',
'lsb-release',
]
state: latest
- name: We add the docker key to the keyring
block:
- name: Ensure directory exists
file:
path: /etc/apt/keyrings
state: directory
mode: '0755'
- name: We download the key
ansible.builtin.apt_key:
url: https://download.docker.com/linux/debian/gpg
keyring: /etc/apt/keyrings/docker.gpg
- name: We add the docker repository
ansible.builtin.apt_repository:
repo: "deb [arch=amd64 signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/debian {{ ansible_distribution_release }} stable"
state: present
filename: docker
- name: Docker installation
apt:
name: [
'docker-ce',
'docker-ce-cli',
'containerd.io',
'docker-buildx-plugin',
'docker-compose-plugin',
]
state: latest
- name: Create a nonroot user to run docker images
ansible.builtin.user:
name: nonroot
shell: /bin/bash
groups: docker
- name: Install python dependencies to use docker community module
block:
- name: Install python pip
apt:
name: python3-pip
state: latest
- name: Install docker pip sdk
ansible.builtin.pip:
name: docker