Compare commits
5 commits
f33ba3c932
...
11a0845bfa
Author | SHA1 | Date | |
---|---|---|---|
11a0845bfa | |||
d8aa02e25c | |||
d7b52fb8de | |||
c3012c032b | |||
e99d5d98c0 |
6 changed files with 69 additions and 0 deletions
|
@ -19,3 +19,6 @@
|
|||
- role: mgrote_docker_compose_inline
|
||||
tags: "compose"
|
||||
become: true
|
||||
- role: mgrote_docker_housekeeping
|
||||
tags: "housekeeping"
|
||||
become: true
|
||||
|
|
3
roles/mgrote_docker_housekeeping/defaults/main.yml
Normal file
3
roles/mgrote_docker_housekeeping/defaults/main.yml
Normal file
|
@ -0,0 +1,3 @@
|
|||
---
|
||||
docker_housekeeping_schedule:
|
||||
...
|
23
roles/mgrote_docker_housekeeping/handlers/main.yml
Normal file
23
roles/mgrote_docker_housekeeping/handlers/main.yml
Normal file
|
@ -0,0 +1,23 @@
|
|||
---
|
||||
- name: systemctl daemon-reload
|
||||
become: true
|
||||
ansible.builtin.systemd:
|
||||
daemon_reload: true
|
||||
|
||||
- name: systemctl enable units
|
||||
become: true
|
||||
ansible.builtin.systemd:
|
||||
name: "{{ item }}"
|
||||
enabled: true
|
||||
masked: false
|
||||
with_items:
|
||||
- docker_housekeeping.service
|
||||
- docker_housekeeping.timer
|
||||
|
||||
- name: systemctl start units
|
||||
become: true
|
||||
ansible.builtin.systemd:
|
||||
name: docker_housekeeping.timer
|
||||
state: restarted
|
||||
enabled: true
|
||||
notify: systemctl daemon-reload
|
23
roles/mgrote_docker_housekeeping/tasks/main.yml
Normal file
23
roles/mgrote_docker_housekeeping/tasks/main.yml
Normal file
|
@ -0,0 +1,23 @@
|
|||
---
|
||||
- name: Setup docker housekeeping tasks
|
||||
become: true
|
||||
ansible.builtin.template:
|
||||
src: docker_housekeeping.service.j2
|
||||
dest: /etc/systemd/system/docker_housekeeping.service
|
||||
owner: root
|
||||
group: root
|
||||
mode: "0644"
|
||||
notify:
|
||||
- systemctl daemon-reload
|
||||
|
||||
- name: Setup timer
|
||||
become: true
|
||||
ansible.builtin.template:
|
||||
src: docker_housekeeping.timer.j2
|
||||
dest: /etc/systemd/system/docker_housekeeping.timer
|
||||
owner: root
|
||||
group: root
|
||||
mode: "0644"
|
||||
notify:
|
||||
- systemctl daemon-reload
|
||||
...
|
|
@ -0,0 +1,7 @@
|
|||
{{ file_header | default () }}
|
||||
[Unit]
|
||||
Description=Docker housekeeping tasks
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
ExecStart=/usr/bin/docker system prune --force
|
|
@ -0,0 +1,10 @@
|
|||
{{ file_header | default () }}
|
||||
[Unit]
|
||||
Description=Timer for docker_housekeeping backups.
|
||||
|
||||
[Timer]
|
||||
OnCalendar={{ docker_housekeeping_schedule }}
|
||||
RandomizedDelaySec=30 min
|
||||
|
||||
[Install]
|
||||
WantedBy=timers.target multi-user.target
|
Loading…
Reference in a new issue