Skip to content

Fixing timer backup job for LDAP servers. #1574

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions docs/roles/debian/ldap_server.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ ldap_server:
purge: false
backup: false # set to true to create local backups of LDAP
backup_path: /opt/slap-bak
backup_script: /usr/local/bin/slap-bak # full filename of the backup script
slapcat_path: /usr/sbin # path to the location of slapcat on the server
on_calendar: "*-*-* 23:45:00" # see systemd.time documentation - https://www.freedesktop.org/software/systemd/man/latest/systemd.time.html#Calendar%20Events
# TLS settings in LDAP are not separately handled, you need to manually set it up or use the config import feature.
# If you use 'manual' SSL handling you need to provide a separate CA certificate.
Expand Down
2 changes: 2 additions & 0 deletions roles/debian/ldap_server/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ ldap_server:
purge: false
backup: false # set to true to create local backups of LDAP
backup_path: /opt/slap-bak
backup_script: /usr/local/bin/slap-bak # full filename of the backup script
slapcat_path: /usr/sbin # path to the location of slapcat on the server
on_calendar: "*-*-* 23:45:00" # see systemd.time documentation - https://www.freedesktop.org/software/systemd/man/latest/systemd.time.html#Calendar%20Events
# TLS settings in LDAP are not separately handled, you need to manually set it up or use the config import feature.
# If you use 'manual' SSL handling you need to provide a separate CA certificate.
Expand Down
2 changes: 2 additions & 0 deletions roles/debian/ldap_server/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ ldap_server:
purge: false
backup: false # set to true to create local backups of LDAP
backup_path: /opt/slap-bak
backup_script: /usr/local/bin/slap-bak # full filename of the backup script
slapcat_path: /usr/sbin # path to the location of slapcat on the server
on_calendar: "*-*-* 23:45:00" # see systemd.time documentation - https://www.freedesktop.org/software/systemd/man/latest/systemd.time.html#Calendar%20Events
# TLS settings in LDAP are not separately handled, you need to manually set it up or use the config import feature.
# If you use 'manual' SSL handling you need to provide a separate CA certificate.
Expand Down
4 changes: 2 additions & 2 deletions roles/debian/ldap_server/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@
- name: Create the slapd backup script.
ansible.builtin.template:
src: slap-bak.j2
dest: /usr/local/bin/slap-bak
dest: "{{ ldap_server.config.backup_script }}"
owner: root
group: root
mode: 0755
Expand All @@ -181,6 +181,6 @@
vars:
timers:
slapd_backups:
timer_command: "/usr/local/bin/slap-bak && find /opt/slap-bak/ -type f -mtime +60 -print0 | xargs -0 -r rm"
timer_command: "{{ ldap_server.config.backup_script }} &> ldap-backup-$( date +%y%m%d-%H%M ).log && find {{ ldap_server.config.backup_path }}/ -type f -mtime +60 -print0 | xargs -0 -r rm"
timer_OnCalendar: "{{ ldap_server.config.on_calendar }}"
when: ldap_server.config.backup
10 changes: 5 additions & 5 deletions roles/debian/ldap_server/templates/slap-bak.j2
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#!/bin/sh
BACKUPDIR="{{ ldap_server.config.backup_path }}"
mkdir -p "$BACKUPDIR"
/usr/bin/mkdir -p "$BACKUPDIR"

CONFIG_LDAPBK="ldap-config-$( date +%y%m%d-%H%M ).ldif"
slapcat -n 0 > "$BACKUPDIR/$CONFIG_LDAPBK"
gzip -9 "$BACKUPDIR/$CONFIG_LDAPBK"
{{ ldap_server.config.slapcat_path }}/slapcat -n 0 > "$BACKUPDIR/$CONFIG_LDAPBK"
/usr/bin/gzip -9 "$BACKUPDIR/$CONFIG_LDAPBK"

DATA_LDAPBK="ldap-data-$( date +%y%m%d-%H%M ).ldif"
slapcat -n 1 > "$BACKUPDIR/$DATA_LDAPBK"
gzip -9 "$BACKUPDIR/$DATA_LDAPBK"
{{ ldap_server.config.slapcat_path }}/slapcat -n 1 > "$BACKUPDIR/$DATA_LDAPBK"
/usr/bin/gzip -9 "$BACKUPDIR/$DATA_LDAPBK"
Loading