deployment/roles/docker/tasks/main.yml

70 lines
1.5 KiB
YAML
Raw Normal View History

2021-12-11 16:28:17 +01:00
---
- name: Ensure older Docker versions aren't installed.
apt:
name:
- docker
- docker-engine
- docker.io
- containerd
- runc
state: absent
- name: Install Docker PPA dependencies.
apt:
name:
- apt-transport-https
- ca-certificates
- gnupg
- lsb-release
state: present
- name: Add Docker GPG key.
apt_key:
url: https://download.docker.com/linux/ubuntu/gpg
state: present
- name: Add Docker PPA.
apt_repository:
# https://gist.github.com/rbq/886587980894e98b23d0eee2a1d84933
repo: "deb [arch={{ ansible_architecture | replace('aarch64', 'arm64') | replace('x86_64', 'amd64') }}] https://download.docker.com/{{ ansible_system | lower }}/{{ ansible_distribution | lower }} {{ ansible_distribution_release }} stable"
state: present
- name: Install Docker, docker-compose & cron.
apt:
update_cache: yes
name:
- docker-ce
- docker-ce-cli
- containerd.io
- docker-compose
- cron
state: present
- name: Ensure Docker is running & enabled.
service:
name: docker
state: started
enabled: true
- name: Add Docker prune cronjob.
cron:
name: Prune the Docker system.
hour: 4
minute: 0
job: docker system prune -af
- name: Add debian user to docker group.
user:
name: debian
groups: docker
append: true
2021-12-12 22:34:38 +01:00
- name: Enable metric endpoint for Prometheus
copy:
src: daemon.json
dest: /etc/docker/daemon.json
owner: root
group: root
mode: '644'
notify: restart docker