Init
This commit is contained in:
commit
aca231c728
8 changed files with 86 additions and 0 deletions
4
README.md
Normal file
4
README.md
Normal file
|
@ -0,0 +1,4 @@
|
|||
Ansible role to configure PostgreSQL
|
||||
===================================
|
||||
|
||||
This is a helper role to run some tasks that are not part of `geerlingguy.postgresql`.
|
11
defaults/main.yml
Normal file
11
defaults/main.yml
Normal file
|
@ -0,0 +1,11 @@
|
|||
---
|
||||
autopostgresqlbackup_delete_backups_after_days: 8
|
||||
|
||||
autopostgresqlbackup_config:
|
||||
dbhost: localhost
|
||||
backupdir: /var/lib/autopostgresqlbackup
|
||||
mailaddr: root
|
||||
sepdir: "yes"
|
||||
comp: bzip2
|
||||
latest: "no"
|
||||
postbackup: /usr/local/bin/autopostgresqlbackup_post_script
|
4
files/systemd/override.conf
Normal file
4
files/systemd/override.conf
Normal file
|
@ -0,0 +1,4 @@
|
|||
# Ansible managed
|
||||
|
||||
[Service]
|
||||
Restart=always
|
9
handlers/main.yml
Normal file
9
handlers/main.yml
Normal file
|
@ -0,0 +1,9 @@
|
|||
---
|
||||
- name: Reload systemd
|
||||
ansible.builtin.systemd:
|
||||
daemon_reload: true
|
||||
|
||||
- name: Restart postgresql
|
||||
ansible.builtin.service:
|
||||
name: postgresql
|
||||
state: restarted
|
10
meta/main.yml
Normal file
10
meta/main.yml
Normal file
|
@ -0,0 +1,10 @@
|
|||
galaxy_info:
|
||||
author: Sense.Lab admins
|
||||
description: Configure PostgreSQL
|
||||
company: Sense.Lab e.V.
|
||||
license: GPLv3
|
||||
min_ansible_version: "2.14"
|
||||
platforms:
|
||||
- name: Debian
|
||||
versions:
|
||||
- bookworm
|
26
tasks/main.yml
Normal file
26
tasks/main.yml
Normal file
|
@ -0,0 +1,26 @@
|
|||
---
|
||||
- name: Install autopostgresqlbackup
|
||||
ansible.builtin.apt:
|
||||
pkg: autopostgresqlbackup
|
||||
update_cache: true
|
||||
|
||||
- name: Copy autopostgresqlbackup configuration
|
||||
ansible.builtin.template:
|
||||
src: autopostgresqlbackup.j2
|
||||
dest: /etc/default/autopostgresqlbackup
|
||||
mode: "0644"
|
||||
|
||||
- name: Copy autopostgresqlbackup postbackup script
|
||||
ansible.builtin.template:
|
||||
src: autopostgresqlbackup_post_script.j2
|
||||
dest: "{{ autopostgresqlbackup_config.postbackup }}"
|
||||
mode: "0755"
|
||||
|
||||
- name: Copy systemd override
|
||||
ansible.builtin.copy:
|
||||
src: systemd/override.conf
|
||||
dest: /etc/systemd/system/postgresql@.service.d/
|
||||
mode: "0644"
|
||||
notify:
|
||||
- Reload systemd
|
||||
- Restart postgresql
|
9
templates/autopostgresqlbackup.j2
Normal file
9
templates/autopostgresqlbackup.j2
Normal file
|
@ -0,0 +1,9 @@
|
|||
# {{ ansible_managed }}
|
||||
|
||||
{% for key, value in autopostgresqlbackup_config.items() %}
|
||||
{% if value is number %}
|
||||
{{ key | upper }}={{ value }}
|
||||
{% else %}
|
||||
{{ key | upper }}="{{ value }}"
|
||||
{% endif %}
|
||||
{% endfor %}
|
13
templates/autopostgresqlbackup_post_script.j2
Normal file
13
templates/autopostgresqlbackup_post_script.j2
Normal file
|
@ -0,0 +1,13 @@
|
|||
### {{ ansible_managed }}
|
||||
|
||||
source /etc/default/autopostgresqlbackup
|
||||
|
||||
# available variables:
|
||||
|
||||
# strings, i.e. character sequences
|
||||
echo "$BACKUPDIR"
|
||||
|
||||
[ -z "$BACKUPDIR" ] && echo >&2 "Invalid / unknown BACKUPDIR" && exit 1
|
||||
|
||||
# Loeschen der alten Backups
|
||||
find "${BACKUPDIR}/monthly" "${BACKUPDIR}/weekly" "${BACKUPDIR}/daily" -type f -mtime +{{ autopostgresqlbackup_delete_backups_after_days }} -delete
|
Loading…
Reference in a new issue