--- # tasks file for borgmatic - name: debug debug: msg: "{{ borgmatic_config_file }}" - name: Assert borg_source_directories not empty assert: that: "{{ borg_source_directories != [] }}" - name: Assert borg_repository not empty assert: that: "{{ borg_repository != [] }}" - name: stat on sources stat: path: "{{ item }}" with_items: "{{ borg_source_directories }}" register: sources_exists - name: Assert sources exists assert: that: "{{ item }}.stat.exists" with_items: "{{ sources_exists.results }}" - name: Install borg and borgmatic apt: name: "{{ item }}" state: present with_items: - borgbackup - borgmatic - name: Make dir for borgmatic in etc file: path: "/etc/borgmatic" state: directory - name: Borgmatic config template: src: config.yaml.j2 dest: "{{ borgmatic_config_file }}" mode: 644 validate: "validate-borgmatic-config -c %s" - name: copy systemd service template: src: service.j2 dest: "/lib/systemd/system/borgmatic_{{ borgmatic_name }}.service" mode: 644 notify: "reload systemd" - name: copy systemd timer for executing borgmatic after boot template: src: afterboot.timer.j2 dest: "/lib/systemd/system/borgmatic_{{ borgmatic_name }}.timer" notify: "reload systemd" - name: disable service systemd: name: "borgmatic_{{ borgmatic_name }}.service" enabled: no - name: enable timer systemd: name: "borgmatic_{{ borgmatic_name }}.timer" enabled: yes