Skip to content
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

Make cron job parameter configurable #1

Merged
merged 2 commits into from
Aug 2, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
1 change: 1 addition & 0 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
postgresql_backup:
enabled: false
directory: ''
cron: '30 03 * * *'
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@alexlanz
do I need the quotes here?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
cron: '30 03 * * *'
time: '30 03 * * *'

You don't need the quotes, but is also no problem if you leave them.

What do you think about giving the property a more specific name?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think cron is actually more explicit then time.

For example in Spring boot you can schedule jobs and they also name it cron:

@Scheduled(cron = "30 03 * * *")

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, works for me

postgresql_users: []
postgresql_databases: []
postgresql_database_permissions: []
Expand Down
1 change: 0 additions & 1 deletion files/postgres

This file was deleted.

1 change: 1 addition & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ PostgreSQL installation role.
privileges: ALL
postgresql_backup:
enabled: true
cron: 30 03 * * *
directory: /usr/local/share/postgres
```

Expand Down
4 changes: 2 additions & 2 deletions tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@
when: postgresql_backup.enabled

- name: Setup PostgreSQL backup script
ansible.builtin.copy:
src: files/postgres
ansible.builtin.template:
src: templates/postgres.j2
dest: /etc/cron.d/postgres
Copy link
Member Author

@mmalfertheiner mmalfertheiner Aug 1, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@alexlanz should we give the cron job a more explicit name? postgres-backup?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great idea

owner: root
group: root
Expand Down
1 change: 1 addition & 0 deletions templates/postgres.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{{ postgresql_backup.cron }} postgres {{ postgresql_backup.directory }}/backup.sh