From 9665ed44de29a24bf3d71bd7ad36ce5fb6fd0780 Mon Sep 17 00:00:00 2001 From: micxer Date: Sat, 18 May 2024 14:39:04 +0200 Subject: [PATCH] feat: Make autorestic configuration file path configurable This commit updates the autorestic configuration file path to use the `autorestic_config_file` variable instead of hardcoding `~/.autorestic.yml`. This change allows for greater flexibility and customization in specifying the location of the configuration file. --- README.md | 8 +++++++- defaults/main.yml | 1 + tasks/main.yml | 6 +++--- tasks/removal.yml | 4 ++-- 4 files changed, 13 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index e4a9b67..a9c3e83 100644 --- a/README.md +++ b/README.md @@ -62,7 +62,13 @@ autorestic_config: B2_ACCOUNT_KEY: Key ``` -The autorestic YAML configuration to be placed into the `~/.autorestic.yml` file. See the [autorestic documentation](https://autorestic.vercel.app/config) for details on the YAML configuration. +See the [autorestic documentation](https://autorestic.vercel.app/config) for details on the YAML configuration. + +```yaml +autorestic_config_file: ~/.autorestic.yml +``` + +The autorestic YAML configuration to be placed into the `~/.autorestic.yml` file. ```yaml autorestic_info: false diff --git a/defaults/main.yml b/defaults/main.yml index 821cc0d..685a068 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -21,6 +21,7 @@ autorestic_config: env: B2_ACCOUNT_ID: ID B2_ACCOUNT_KEY: Key +autorestic_config_file: ~/.autorestic.yml autorestic_info: false autorestic_check: false autorestic_cron: false diff --git a/tasks/main.yml b/tasks/main.yml index 5c9c708..9ed1b0d 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -48,7 +48,7 @@ - name: Create autorestic configuration file ansible.builtin.copy: content: "{{ autorestic_config | to_yaml }}" - dest: ~/.autorestic.yml + dest: {{ autorestic_config_file }} mode: "0600" - name: Run autorestic info @@ -79,7 +79,7 @@ minute: "*/5" job: | {% if autorestic_cron_verbose == true %} - autorestic -c ~/.autorestic.yml --ci cron -vvvvv > /tmp/autorestic.log 2>&1 + autorestic -c {{ autorestic_config_file }} --ci cron -vvvvv > /tmp/autorestic.log 2>&1 {% else %} - autorestic -c ~/.autorestic.yml --ci cron > /tmp/autorestic.log 2>&1 + autorestic -c {{ autorestic_config_file }} --ci cron > /tmp/autorestic.log 2>&1 {% endif %} diff --git a/tasks/removal.yml b/tasks/removal.yml index 57ad6ea..f026648 100644 --- a/tasks/removal.yml +++ b/tasks/removal.yml @@ -11,7 +11,7 @@ - name: Remove autorestic configuration file ansible.builtin.file: - path: ~/.autorestic.yml + path: {{ autorestic_config_file }} state: absent - name: Remove restic binary @@ -37,5 +37,5 @@ ansible.builtin.cron: name: Configure autorestic crontab job minute: "*/5" - job: autorestic -c ~/.autorestic.yml --ci cron > /tmp/autorestic.log 2>&1 + job: autorestic -c {{ autorestic_config_file }} --ci cron > /tmp/autorestic.log 2>&1 state: absent