Skip to content

Commit

Permalink
feat: Make autorestic configuration file path configurable
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
micxer committed May 18, 2024
1 parent c71eb37 commit 9665ed4
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 6 deletions.
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 %}
4 changes: 2 additions & 2 deletions tasks/removal.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

0 comments on commit 9665ed4

Please sign in to comment.