Update module names

This commit is contained in:
Stanislas Lange 2022-10-11 19:11:50 +02:00
parent de417427f0
commit b283222c79
No known key found for this signature in database
4 changed files with 32 additions and 34 deletions

View file

@ -7,9 +7,9 @@ restic_user_home: /root
restic_repository_name: restic
restic_default_folders:
- { path: '/etc' }
- { path: '/var/log' }
- { path: '/root', exclude: '--exclude .cache' }
- { path: "/etc" }
- { path: "/var/log" }
- { path: "/root", exclude: "--exclude .cache" }
restic_folders: []
restic_databases: []
restic_dump_compression_enabled: false
@ -21,7 +21,7 @@ restic_check: true
restic_ssh_enabled: true
restic_ssh_host: backup
restic_ssh_port: 22
restic_ssh_private_key_path: '/root/.ssh/backup'
restic_ssh_private_key_path: "/root/.ssh/backup"
restic_systemd_timer_on_calender: '*-*-* 03:00:00'
restic_systemd_timer_on_calender: "*-*-* 03:00:00"
restic_systemd_timer_randomized_delay_sec: 0

View file

@ -1,5 +1,4 @@
---
- name: systemd reload
systemd:
ansible.builtin.systemd:
daemon_reload: yes

View file

@ -1,5 +1,4 @@
---
- name: Install fuse (to mount repositories)
apt:
name: fuse
@ -13,23 +12,23 @@
name: pigz
- name: Download restic
get_url:
url: 'https://github.com/restic/restic/releases/download/v{{ restic_version }}/restic_{{ restic_version }}_linux_amd64.bz2'
dest: '/tmp/restic_{{ restic_version }}_linux_amd64.bz2'
ansible.builtin.get_url:
url: "https://github.com/restic/restic/releases/download/v{{ restic_version }}/restic_{{ restic_version }}_linux_amd64.bz2"
dest: "/tmp/restic_{{ restic_version }}_linux_amd64.bz2"
- name: Extract restic
command: 'bzip2 -d /tmp/restic_{{ restic_version }}_linux_amd64.bz2'
command: "bzip2 -d /tmp/restic_{{ restic_version }}_linux_amd64.bz2"
args:
creates: '/tmp/restic_{{ restic_version }}_linux_amd64'
creates: "/tmp/restic_{{ restic_version }}_linux_amd64"
- name: Install restic
copy:
ansible.builtin.copy:
remote_src: true
src: '/tmp/restic_{{ restic_version }}_linux_amd64'
src: "/tmp/restic_{{ restic_version }}_linux_amd64"
dest: "{{ restic_path }}"
mode: 0755
- name: Remove downloaded file
file:
path: '/tmp/restic_{{ restic_version }}_linux_amd64'
ansible.builtin.file:
path: "/tmp/restic_{{ restic_version }}_linux_amd64"
state: absent

View file

@ -1,54 +1,54 @@
---
- name: Check if restic is installed
stat:
path: '{{ restic_path }}'
ansible.builtin.stat:
path: "{{ restic_path }}"
register: restic_binary
- include_tasks: install.yml
when: not restic_binary.stat.exists or restic_install
- name: Overwrite SSH config for backup server
template:
ansible.builtin.template:
src: ssh_config.j2
dest: '{{ restic_user_home }}/.ssh/config'
dest: "{{ restic_user_home }}/.ssh/config"
owner: root
group: root
mode: '0600'
mode: "0600"
when: restic_ssh_enabled
- name: Add SSH private key
template:
ansible.builtin.template:
src: ssh_private_key.j2
dest: '{{ restic_ssh_private_key_path }}'
mode: '0600'
dest: "{{ restic_ssh_private_key_path }}"
mode: "0600"
when: restic_ssh_private_key is defined and restic_ssh_enabled
- name: Add restic_env in home folder
template:
ansible.builtin.template:
src: restic_env.j2
dest: '{{ restic_user_home }}/.restic_env'
dest: "{{ restic_user_home }}/.restic_env"
owner: root
group: root
mode: '0600'
mode: "0600"
- name: Add systemd service for restic
template:
ansible.builtin.template:
src: restic-backup.service.j2
dest: /etc/systemd/system/restic-backup.service
mode: '0644'
mode: "0644"
vars:
restic_folders_combined: '{{ restic_default_folders + restic_folders }}'
restic_folders_combined: "{{ restic_default_folders + restic_folders }}"
notify: systemd reload
- name: Add systemd timer for restic
template:
ansible.builtin.template:
src: restic-backup.timer.j2
dest: /etc/systemd/system/restic-backup.timer
mode: '0644'
mode: "0644"
notify: systemd reload
- name: Enable and start restic timer
systemd:
ansible.builtin.systemd:
name: restic-backup.timer
enabled: true
state: started