lab-ansible/roles/docker/tasks/main.yml
2023-11-12 16:56:40 +01:00

52 lines
1.4 KiB
YAML

# vim: ft=yaml.ansible
# code: language=ansible
---
- name: Add Docker PGP key
ansible.builtin.rpm_key:
key: https://download.docker.com/linux/centos/gpg
fingerprint: 060A 61C5 1B55 8A7F 742B 77AA C52F EB6B 621E 9F35
state: present
- name: Add Docker repository
ansible.builtin.yum_repository:
name: docker-ce-stable
description: Docker CE Stable - $basearch
file: docker-ce
baseurl: https://download.docker.com/linux/centos/$releasever/$basearch/stable
gpgkey: https://download.docker.com/linux/centos/gpg
gpgcheck: true
enabled: true
state: present
- name: Install Docker and Docker Compose
ansible.builtin.dnf:
name:
- docker-ce
- docker-ce-cli
- docker-compose-plugin
- containerd.io
state: present
- name: Copy Docker daemon config file
ansible.builtin.template:
src: etc/docker/daemon.json.j2
dest: /etc/docker/daemon.json
owner: root
mode: u=rw,g=r,o=r
notify: Reload Docker daemon
- name: Ensure Docker daemon is enabled and running
ansible.builtin.service:
name: docker
enabled: true
state: started
- name: Configure cron job to prune unused Docker data daily
ansible.builtin.cron:
name: Prune unused Docker data
cron_file: ansible_docker_prune
job: 'docker system prune -fa && docker volume prune -fa'
special_time: daily
user: root
state: present