Homelab-Ansible/ansible/install_docker.yaml

43 lines
1.8 KiB
YAML

- name: Setup Docker hosts
hosts:
- docker
vars:
tasks:
- name: Docker Prereqs
ansible.builtin.apt:
update_cache: true
name:
- ca-certificates
- curl
- gnupg
- lsb-release
- name: Create keyring directory
ansible.builtin.file:
path: /etc/apt/keyrings
state: directory
- name: Create Docker directory
ansible.builtin.file:
path: /root/docker
state: directory
## TODO: Detect OS
# - name: Download Docker GPG keys
# ansible.builtin.shell: curl -fsSL https://download.docker.com/linux/ubuntu/gpg | gpg --dearmor -o /etc/apt/keyrings/docker.gpg --batch --yes
# - name: Add Docker repo
# ansible.builtin.shell: echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | tee /etc/apt/sources.list.d/docker.list > /dev/null
- name: Install Docker keyring
ansible.builtin.shell: install -m 0755 -d /etc/apt/keyrings
- name: Download Docker GPG keys
ansible.builtin.shell: curl -fsSL https://download.docker.com/linux/debian/gpg -o /etc/apt/keyrings/docker.asc
- name: chmod keyring
ansible.builtin.shell: chmod a+r /etc/apt/keyrings/docker.asc
- name: Add Docker repo
ansible.builtin.shell: echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/debian $(. /etc/os-release && echo "$VERSION_CODENAME") stable" | tee /etc/apt/sources.list.d/docker.list > /dev/null
- name: Install Docker
ansible.builtin.apt:
update_cache: true
name:
- docker-ce
- docker-ce-cli
- containerd.io
- docker-compose-plugin