Skip to content
This repository has been archived by the owner on Jun 12, 2020. It is now read-only.

Commit

Permalink
remove custom installation path to restic binary
Browse files Browse the repository at this point in the history
Software installations should adhere to 'man hier(7)'
  • Loading branch information
paulfantom committed Mar 27, 2019
1 parent ce5a075 commit 863c153
Show file tree
Hide file tree
Showing 8 changed files with 10 additions and 17 deletions.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 |
Expand Down
3 changes: 0 additions & 3 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
1 change: 0 additions & 1 deletion molecule/alternative/playbook.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions tasks/configure.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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 }}"
Expand Down
11 changes: 3 additions & 8 deletions tasks/install.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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 }}'
Expand All @@ -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
2 changes: 1 addition & 1 deletion templates/restic.cron.j2
Original file line number Diff line number Diff line change
Expand Up @@ -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 %}
Expand Down
2 changes: 1 addition & 1 deletion templates/restic.helper.j2
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions vars/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,6 @@ go_arch_map:
aarch64: arm64
armv7l: arm
armv6l: arm

_restic_home: "/var/lib/restic"
_restic_install_path: '/usr/local/bin'

0 comments on commit 863c153

Please sign in to comment.