Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 9665ed4

Browse files
committedMay 18, 2024··
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.
1 parent c71eb37 commit 9665ed4

File tree

4 files changed

+13
-6
lines changed

4 files changed

+13
-6
lines changed
 

‎README.md

+7-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,13 @@ autorestic_config:
6262
B2_ACCOUNT_KEY: Key
6363
```
6464

65-
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.
65+
See the [autorestic documentation](https://autorestic.vercel.app/config) for details on the YAML configuration.
66+
67+
```yaml
68+
autorestic_config_file: ~/.autorestic.yml
69+
```
70+
71+
The autorestic YAML configuration to be placed into the `~/.autorestic.yml` file.
6672

6773
```yaml
6874
autorestic_info: false

‎defaults/main.yml

+1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ autorestic_config:
2121
env:
2222
B2_ACCOUNT_ID: ID
2323
B2_ACCOUNT_KEY: Key
24+
autorestic_config_file: ~/.autorestic.yml
2425
autorestic_info: false
2526
autorestic_check: false
2627
autorestic_cron: false

‎tasks/main.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
- name: Create autorestic configuration file
4949
ansible.builtin.copy:
5050
content: "{{ autorestic_config | to_yaml }}"
51-
dest: ~/.autorestic.yml
51+
dest: {{ autorestic_config_file }}
5252
mode: "0600"
5353

5454
- name: Run autorestic info
@@ -79,7 +79,7 @@
7979
minute: "*/5"
8080
job: |
8181
{% if autorestic_cron_verbose == true %}
82-
autorestic -c ~/.autorestic.yml --ci cron -vvvvv > /tmp/autorestic.log 2>&1
82+
autorestic -c {{ autorestic_config_file }} --ci cron -vvvvv > /tmp/autorestic.log 2>&1
8383
{% else %}
84-
autorestic -c ~/.autorestic.yml --ci cron > /tmp/autorestic.log 2>&1
84+
autorestic -c {{ autorestic_config_file }} --ci cron > /tmp/autorestic.log 2>&1
8585
{% endif %}

‎tasks/removal.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
- name: Remove autorestic configuration file
1313
ansible.builtin.file:
14-
path: ~/.autorestic.yml
14+
path: {{ autorestic_config_file }}
1515
state: absent
1616

1717
- name: Remove restic binary
@@ -37,5 +37,5 @@
3737
ansible.builtin.cron:
3838
name: Configure autorestic crontab job
3939
minute: "*/5"
40-
job: autorestic -c ~/.autorestic.yml --ci cron > /tmp/autorestic.log 2>&1
40+
job: autorestic -c {{ autorestic_config_file }} --ci cron > /tmp/autorestic.log 2>&1
4141
state: absent

0 commit comments

Comments
 (0)
Please sign in to comment.