Skip to content

Commit

Permalink
add restic configuration steps
Browse files Browse the repository at this point in the history
create a password and add fake gce_credentials to source environment
  • Loading branch information
kayiwa committed Sep 4, 2023
1 parent e66dc34 commit fbc3d00
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 1 deletion.
8 changes: 8 additions & 0 deletions roles/restic/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,10 @@
---
# defaults file for restic
restic_user: "restic"
restice_user_home: "/home/{{ restic_user }}"
restic_home: "{{ restic_user_home }}/.restic"
restic_local_repo: "/var/local/demo_backup"
restic_remote_repo: "gs:deadbeef:daily"
restic_gce_credentials: "{{ restic_home }}/pul-gcdc-33c75c1ceece.json"
restic_password: "CHANGEME"
restic_password_file: "{{ restic_user_home }}/.restic.pwd"
2 changes: 1 addition & 1 deletion roles/restic/molecule/default/molecule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ lint: |
ansible-lint
platforms:
- name: instance
image: "pulibrary/puldocker-${MOLECULE_DISTRO:-ubuntu1804}-ansible:latest"
image: "quay.io/pulibrary/jammy-ansible:latest"
command: ""
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:ro
Expand Down
30 changes: 30 additions & 0 deletions roles/restic/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,32 @@
---
# tasks file for restic
- name: Install Restic Software
ansible.builtin.apt:
name: restic
state: present

- name: Create restic directory if it does not exist
ansible.builtin.file:
path: "{{ restic_home }}"
state: directory
mode: o-rwx

- name: Add restic credentials
ansible.builtin.template:
src: restic.pwd.j2
dest: "{{ restic_user_home }}/.restic.pwd"
owner: "{{ restic_user }}"
group: "{{ restic_user }}"
mode: o-r

- name: Add restic environment
ansible.builtin.template:
src: env.restic.j2
dest: "{{ restic_user_home }}/.env.restic"
owner: "{{ restic_user }}"
group: "{{ restic_user }}"
mode: o-rwx

- name: Source Restic environment
ansible.builtin.shell: "source ~/.env.restic"
changed_when: false
10 changes: 10 additions & 0 deletions roles/restic/templates/env.restic.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
### repository on local filesystem
export RESTIC_ARCHIVE_REPOSITORY='{{ restic_local_repo }}'

### repository on google cloud
export GOOGLE_APPLICATION_CREDENTIALS='{{ restic_gce_credentials }}'

export RESTIC_ARCHIVE_REPOSITORY='{{ restic_remote_repo }}'

export RESTIC_REPOSITORY=$RESTIC_ARCHIVE_REPOSITORY
export RESTIC_PASSWORD_FILE='{{ restic_password_file }}'
1 change: 1 addition & 0 deletions roles/restic/templates/restic.pwd.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"{{ restic_password }}"

0 comments on commit fbc3d00

Please sign in to comment.