1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 |
- - name: install duplicity
- apt:
- name: '{{duplitab_duplicity_package_name}}'
- state: present
- become: yes
- - name: install sshfs
- apt:
- name: sshfs
- state: present
- become: yes
- - name: install duplitab package
- copy:
- src: '{{duplitab_package_source_path}}'
- dest: '{{duplitab_package_install_path}}'
- become: yes
- register: duplitab_package
- - name: install duplitab
- apt:
- deb: '{{duplitab_package.dest}}'
- state: present
- become: yes
- - name: generate backup config
- set_fact:
- source_type: "{{item.0.source_host is defined | ternary('sshfs', 'local')}}"
- source_host: "{{item.0.source_host | default(None)}}"
- source_path: "{{item.0.source_path}}"
- selectors: "{{item.0.selectors|default([])}}"
- target_url: "{{item.1.url}}"
- target_via_sshfs: "{{item.1.sshfs | default(False)}}"
- encrypt_key: "{{item.1.encrypt_key | default(None)}}"
- encryption: "{{item.1.encrypt_key is defined}}"
- with_subelements:
- - '{{duplitab_backups}}'
- - targets
- register: duplitab_config
- - name: write /etc/duplitab
- copy:
- content: "{{duplitab_config.results | map(attribute = 'ansible_facts') | list | to_nice_yaml}}"
- dest: /etc/duplitab
- become: yes
- - name: setup cron jobs
- blockinfile:
- dest: '/etc/crontab'
- marker: '# ANSIBLE DUPLITAB BACKUPS {mark}'
- block: |-
- {% for job in duplitab_cron_jobs %}
- {{job.minute}} {{job.hour}} * * * {{job.local_user}} duplitab
- {%- if job.target_url_filter is defined %}
- --filter-target-url '{{job.target_url_filter}}'
- {%- endif %}
- {%- if job.quiet | default(True) %}
- --quiet
- {%- endif %}
- backup
- {% endfor %}
- become: yes
|