2018-10-06 14:04:20 +02:00
|
|
|
---
|
|
|
|
- name: Regenerate apt-cache and update packages
|
2019-02-28 11:40:24 +01:00
|
|
|
apt:
|
|
|
|
update_cache: yes
|
|
|
|
cache_valid_time: 120
|
2018-10-06 14:04:20 +02:00
|
|
|
|
|
|
|
- name: Install required System Packages
|
|
|
|
apt:
|
|
|
|
pkg: "{{ item }}"
|
|
|
|
state: installed
|
|
|
|
with_items: "{{ borg_apt_packages }}"
|
|
|
|
|
2019-02-28 11:40:24 +01:00
|
|
|
- name: Update setuptools if needed
|
|
|
|
pip:
|
|
|
|
name: setuptools
|
|
|
|
state: latest
|
|
|
|
executable: pip3
|
|
|
|
|
2018-10-06 14:04:20 +02:00
|
|
|
- name: Install required Python Packages
|
|
|
|
pip:
|
|
|
|
name: "{{ item }}"
|
|
|
|
executable: pip3
|
|
|
|
with_items: "{{ borg_python_packages }}"
|
|
|
|
|
|
|
|
- name: Ensure root has SSH key.
|
|
|
|
user:
|
|
|
|
name: "root"
|
|
|
|
generate_ssh_key: yes
|
|
|
|
ssh_key_file: .ssh/id_ed25519
|
|
|
|
ssh_key_type: ed25519
|
|
|
|
register: root_user
|
|
|
|
|
|
|
|
- debug:
|
|
|
|
var: root_user['ssh_public_key']
|
|
|
|
|
|
|
|
- name: Ensures /etc/borgmatic exists
|
|
|
|
file:
|
|
|
|
path: /etc/borgmatic
|
|
|
|
state: directory
|
|
|
|
mode: 0700
|
|
|
|
owner: root
|
|
|
|
|
|
|
|
- name: Add Borgmatic Configuration
|
|
|
|
template:
|
|
|
|
src: config.yaml.j2
|
2018-10-29 04:27:25 +01:00
|
|
|
dest: "/etc/borgmatic/{{ borgmatic_config_name }}"
|
2018-10-06 14:04:20 +02:00
|
|
|
mode: 0600
|
|
|
|
|
2019-05-01 04:39:07 +02:00
|
|
|
- name: Add cron-job for borgmatic (large repo, create and prune)
|
2018-10-06 14:04:20 +02:00
|
|
|
cron:
|
2019-05-01 04:39:07 +02:00
|
|
|
name: "borgmatic-create"
|
|
|
|
hour: "{{ 6 |random }}"
|
|
|
|
minute: "{{ 59 |random }}"
|
|
|
|
user: "root"
|
|
|
|
cron_file: borgmatic
|
|
|
|
job: "/usr/local/bin/borgmatic -c /etc/borgmatic/{{ borgmatic_config_name }} --create --prune"
|
|
|
|
when: borgmatic_large_repo
|
|
|
|
|
|
|
|
- name: Add cron-job for borgmatic (large repo, check)
|
|
|
|
cron:
|
|
|
|
name: "borgmatic-check"
|
|
|
|
weekday: 0
|
|
|
|
hour: "{{ range(7, 24) |random }}"
|
|
|
|
minute: "{{ 59 |random }}"
|
|
|
|
user: "root"
|
|
|
|
cron_file: borgmatic
|
|
|
|
job: "/usr/local/bin/borgmatic -c /etc/borgmatic/{{ borgmatic_config_name }} --check"
|
|
|
|
when: borgmatic_large_repo
|
|
|
|
|
|
|
|
- name: Add cron-job for borgmatic (normal-sized repo)
|
|
|
|
cron:
|
|
|
|
name: "borgmatic-create"
|
|
|
|
hour: "{{ 6 |random }}"
|
2018-10-06 14:04:20 +02:00
|
|
|
minute: "{{ 59 |random }}"
|
|
|
|
user: "root"
|
|
|
|
cron_file: borgmatic
|
2018-10-29 04:27:25 +01:00
|
|
|
job: "/usr/local/bin/borgmatic -c /etc/borgmatic/{{ borgmatic_config_name }}"
|
2019-05-01 04:39:07 +02:00
|
|
|
when: not borgmatic_large_repo
|
2018-10-11 09:08:57 +02:00
|
|
|
|
|
|
|
- name: Set PATH for borgmatic cron job.
|
|
|
|
cron:
|
|
|
|
user: "root"
|
|
|
|
cron_file: borgmatic
|
|
|
|
name: PATH
|
|
|
|
env: yes
|
2018-10-29 04:27:25 +01:00
|
|
|
value: /usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
|