lab-ansible/roles/docker/tasks/main.yml

52 lines
1.4 KiB
YAML
Raw Normal View History

2023-10-29 19:46:52 +00:00
# vim: ft=yaml.ansible
# code: language=ansible
---
- name: Add Docker PGP key
2023-11-12 15:41:59 +00:00
ansible.builtin.rpm_key:
key: https://download.docker.com/linux/centos/gpg
fingerprint: 060A 61C5 1B55 8A7F 742B 77AA C52F EB6B 621E 9F35
2023-10-29 19:46:52 +00:00
state: present
2023-11-12 15:41:59 +00:00
- 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
2023-10-29 19:46:52 +00:00
state: present
2023-11-12 15:41:59 +00:00
- name: Install Docker and Docker Compose
ansible.builtin.dnf:
name:
2023-10-29 19:46:52 +00:00
- docker-ce
2023-11-12 15:41:59 +00:00
- docker-ce-cli
2023-10-29 19:46:52 +00:00
- docker-compose-plugin
2023-11-12 15:41:59 +00:00
- containerd.io
state: present
2023-10-29 19:46:52 +00:00
2023-12-25 20:49:17 +00:00
- name: Copy Docker daemon config file
ansible.builtin.copy:
src: daemon.json
dest: /etc/docker/daemon.json
owner: root
mode: u=rw,g=r,o=r
notify: Reload Docker daemon
2023-10-29 19:46:52 +00:00
- name: Ensure Docker daemon is enabled and running
ansible.builtin.service:
name: docker
enabled: true
state: started
2023-11-11 15:35:14 +00:00
- name: Configure cron job to prune unused Docker data daily
2023-10-29 19:46:52 +00:00
ansible.builtin.cron:
name: Prune unused Docker data
cron_file: ansible_docker_prune
job: 'docker system prune -fa && docker volume prune -fa'
2023-11-11 15:35:14 +00:00
special_time: daily
2023-10-29 19:46:52 +00:00
user: root
state: present