-
Notifications
You must be signed in to change notification settings - Fork 0
/
maintenance.yaml
52 lines (49 loc) · 1.22 KB
/
maintenance.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
---
# Routine maintenance script
# Plays
- name: Upgrade packages
hosts: all
become: yes
tasks:
# https://docs.ansible.com/ansible/latest/collections/ansible/builtin/apt_module.html
- name: Clean repositories
apt:
autoclean: yes
autoremove: yes
- name: Purge repositories
apt:
purge: yes
- name: Upgrade packages
apt:
update_cache: yes
upgrade: full
# https://www.postgresql.org/docs/12/maintenance.html
- name: PostgreSQL routine maintenance
hosts: airbods.my-domain.com
become: yes
tasks:
# https://www.postgresql.org/docs/12/backup.html
# https://stribny.name/blog/ansible-postgresql-backups/
- name: SQL Backup
become: yes
become_user: postgres
postgresql_db:
state: dump
name: airbods
target: /home/postgres/airbods.sql.gz
# https://www.postgresql.org/docs/12/routine-vacuuming.html
- name: Vacuum
become: yes
become_user: postgres
postgresql_query:
db: airbods
query: "VACUUM"
autocommit: yes
- name: Delete old log files
hosts: all
become: yes
tasks:
- name: Remove old logs
shell:
cmd: "journalctl --vacuum-size=1G"
...