diff --git a/README.md b/README.md index 09059ab..914db4e 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,6 @@ All variables which can be overridden are stored in [defaults/main.yml](defaults | `restic_user` | "root" | system user to run restic | | `restic_group` | "root" | system group to run restic | | `restic_shell` | "/bin/false" | the shell for the restic user, change this if you want to be able to su to it | -| `restic_install_path` | "/usr/local/bin" | directory where restic binary will be installed | | `restic_cron_mailto` | restic_user | who to mail results of the restic crons to, set to "" to not mail | | `restic_cron_stdout_file` | null | what file to log restic output to, null means include in mailto, use /dev/null to discard | | `restic_cron_stderr_file` | null | what file to log restic errors to, null means include in mailto, use /dev/null to discard | diff --git a/defaults/main.yml b/defaults/main.yml index 9749f2e..49b0bc1 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -4,9 +4,6 @@ restic_version: '0.9.4' restic_user: root restic_group: "{{ restic_user }}" restic_shell: "/bin/false" -restic_home: "/var/lib/restic" - -restic_install_path: '/usr/local/bin' restic_initialize_repos: true diff --git a/molecule/alternative/playbook.yml b/molecule/alternative/playbook.yml index cd66ced..0f8e1b3 100644 --- a/molecule/alternative/playbook.yml +++ b/molecule/alternative/playbook.yml @@ -8,7 +8,6 @@ restic_version: 'latest' restic_user: restic restic_group: restic - restic_install_path: "/opt" restic_initialize_repos: false restic_repos: - name: s3-example diff --git a/tasks/configure.yml b/tasks/configure.yml index 9653f40..7e4132d 100644 --- a/tasks/configure.yml +++ b/tasks/configure.yml @@ -11,7 +11,7 @@ - name: Deploy helper commands template: src: 'restic.helper.j2' - dest: "{{ restic_install_path }}/restic-{{ item.name }}" + dest: "{{ _restic_install_path }}/restic-{{ item.name }}" owner: "{{ restic_user }}" group: "{{ restic_group }}" mode: '0750' @@ -29,7 +29,7 @@ when: restic_user != 'root' - name: Initialize restic repositories - command: "{{ restic_install_path }}/restic-{{ item.name }} init" + command: "{{ _restic_install_path }}/restic-{{ item.name }} init" ignore_errors: true no_log: true with_items: "{{ restic_repos }}" diff --git a/tasks/install.yml b/tasks/install.yml index 6fbc054..ecd3381 100644 --- a/tasks/install.yml +++ b/tasks/install.yml @@ -11,15 +11,10 @@ shell: "{{ restic_shell }}" system: true createhome: true - home: "{{ restic_home }}" + home: "{{ _restic_home }}" state: present when: restic_user != 'root' -- name: Ensure restic installation directory exist - file: - state: 'directory' - path: '{{ restic_install_path }}' - - name: Ensure restic user can write to log dirs if defined file: state: 'directory' @@ -67,7 +62,7 @@ - name: Propagate restic binary copy: src: "/tmp/restic_{{ restic_version }}_{{ go_arch_map[ansible_architecture] | default(ansible_architecture) }}" - dest: '{{ restic_install_path }}/restic' + dest: '{{ _restic_install_path }}/restic' mode: '0750' owner: 'root' group: '{{ restic_group }}' @@ -80,7 +75,7 @@ - name: Set proper capabilities for restic binary capabilities: - path: '{{ restic_install_path }}/restic' + path: '{{ _restic_install_path }}/restic' capability: cap_dac_read_search+ep state: present when: not ansible_check_mode diff --git a/templates/restic.cron.j2 b/templates/restic.cron.j2 index 62f931a..cef85d0 100644 --- a/templates/restic.cron.j2 +++ b/templates/restic.cron.j2 @@ -2,7 +2,7 @@ {{ ansible_managed | comment }} MAILTO="{{ restic_cron_mailto }}" SHELL=/bin/sh -PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:{{ restic_install_path }} +PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:{{ _restic_install_path }} RESTIC_REPOSITORY={{ item.url | trim | quote }} RESTIC_PASSWORD={{ item.password | trim | quote }} {% if item.remote_credentials is defined %} diff --git a/templates/restic.helper.j2 b/templates/restic.helper.j2 index a5e795f..e7fcfe6 100644 --- a/templates/restic.helper.j2 +++ b/templates/restic.helper.j2 @@ -4,7 +4,7 @@ # vi: ft=jinja.crontab {{ ansible_managed | comment }} ( - PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:{{ restic_install_path }} + PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:{{ _restic_install_path }} export PATH RESTIC_REPOSITORY={{ item.url | trim | quote }} export RESTIC_REPOSITORY diff --git a/vars/main.yml b/vars/main.yml index f8f9e3d..0e93366 100644 --- a/vars/main.yml +++ b/vars/main.yml @@ -5,3 +5,6 @@ go_arch_map: aarch64: arm64 armv7l: arm armv6l: arm + +_restic_home: "/var/lib/restic" +_restic_install_path: '/usr/local/bin'