Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

unification #36

Open
wants to merge 21 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 24 additions & 2 deletions defaults/main.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
---

#python_install: b2

backup_enabled: yes # Enable the role
backup_remove: no # Set yes for uninstall the role from target system
backup_cron: yes # Setup cron tasks for backup

backup_duplicity_ppa: ppa:duplicity-team/duplicity-release-git # Install newest version from repo

backup_user: root # Run backups as user
backup_group: "{{backup_user}}"
backup_group: "{{ backup_user }}"

backup_home: /etc/duply # Backup configuration directory
backup_work: /var/duply # Working directory
Expand Down Expand Up @@ -35,7 +39,11 @@ backup_profiles: [] # Setup backup profiles
# max_age: 10D
# target: s3://my.bucket/www
# exclude:
# - *.pyc
# - "+ /var/www/folder1"
# - "+ /var/www/folder2"
# - "- **/folder3/*.log"
# - "+ **/folder3"
# - "- **"
# - name: postgresql
# schedule: 0 4 * * *
# action: restore # Choose action: backup/restore (default is backup)
Expand Down Expand Up @@ -92,3 +100,17 @@ backup_volsize: 50
backup_verbosity: 3

backup_exclude: [] # List of filemasks to exlude

backup_include: [] # List of filemasks to exlude

backup_credential_files: [] # List of credential file

backup_credential_hubic_email:
backup_credential_hubic_password:
backup_credential_hubic_client_id:
backup_credential_hubic_client_secret:
backup_credential_hubic_redirect_uri:

backup_profiles_exclude_list_host: []
backup_profiles_exclude_list_group: []
backup_profiles_exclude_list_all: []
3 changes: 2 additions & 1 deletion meta/main.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---

dependencies: []
dependencies:
- { role: geerlingguy.pip, pip_package: python3-pip, pip_install_packages: [b2]}

galaxy_info:
author: klen
Expand Down
9 changes: 9 additions & 0 deletions tasks/configure.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,12 @@

- name: backup-configure | Configure logrotate
template: src=logrotate.j2 dest=/etc/logrotate.d/backup owner=root group=root mode=0644

- name: deploy credential files to home directory
become: true
become_user: "{{backup_user}}"
template:
src: "{{ item }}.j2"
dest: "{{ ansible_env.HOME }}/.{{ item }}"
with_items:
- "{{ backup_credential_files }}"
25 changes: 19 additions & 6 deletions tasks/install.deb.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,26 @@

- include_vars: "{{ansible_distribution}}.yml"

# This is required until duplicity works with python3.8 (ubuntu 20.04)
- name: Install python 3.7 - add repo
apt_repository:
repo: ppa:deadsnakes/ppa
state: present
update_cache: yes

- name: Install python 3.7 - install package
package:
name: python3.7
state: present

- name: Adding repository
apt_repository:
repo: "{{ backup_duplicity_ppa }}"
state: present
when: backup_duplicity_ppa is defined

- name: Install dependencies
apt: name={{item}}
with_items:
- cron
- gzip
- python-boto
- s3cmd
apt: name={{ dependencies }}

- set_fact: backup_duplicity_pkg="{{backup_duplicity_pkg}}={{backup_duplicity_version}}"
when: backup_duplicity_version
Expand Down
16 changes: 10 additions & 6 deletions tasks/install.red.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
---

- include_vars: "{{ ansible_os_family }}.yml"

- name: Ensure libselinux-python is installed
yum: name=libselinux-python

Expand All @@ -13,13 +15,15 @@
key: "/etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-{{ ansible_distribution_major_version }}"
state: present

- name: Remove urllib3 because it will be installed as a dependency later on with rpm
pip:
name: urllib3
state: absent

- name: Install dependencies
yum: name={{item}}
with_items:
- cronie
- gzip
- python-boto
- s3cmd
yum:
name: "{{ dependencies }}"
update_cache: yes

- set_fact: backup_duplicity_pkg="{{backup_duplicity_pkg}}-{{backup_duplicity_version}}"
when: backup_duplicity_version
Expand Down
5 changes: 5 additions & 0 deletions templates/conf.j2
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,12 @@
{% else %}
GPG_KEY='{{ item.gpg_key|default(backup_gpg_key) }}'
{% endif %}
{% if item.gpg_pw|default(backup_gpg_pw) == 'disabled' %}
GPG_KEY='disabled'
#GPG_PW='{{ item.gpg_pw|default(backup_gpg_pw) }}'
{% else %}
GPG_PW='{{ item.gpg_pw|default(backup_gpg_pw) }}'
{% endif %}
{% if item.gpg_keys_enc|default(None) %}
GPG_KEYS_ENC='{{item.gpg_keys_enc}}'
{% endif %}
Expand Down
4 changes: 3 additions & 1 deletion templates/cron.j2
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,7 @@
{% if profile.schedule|default(None) %}
{{profile.schedule}} {{profile.user|default(backup_user)}} /usr/bin/duply {{backup_home}}/{{profile.name}} {{profile.action|default('backup')}} >> {{backup_logdir}}/{{profile.name}}.log 2>&1
{% endif %}
{% if profile.schedule2|default(None) %}
{{profile.schedule2}} {{profile.user|default(backup_user)}} /usr/bin/duply {{backup_home}}/{{profile.name}} {{profile.action2|default('backup_verify_purge --force')}} >> {{backup_logdir}}/{{profile.name}}.log 2>&1
{% endif %}
{% endfor %}

Loading