mirror of
https://github.com/borgbase/ansible-role-borgbackup.git
synced 2024-11-19 19:07:42 +01:00
Allow to installation via OS package manager or pip (#106)
* allow to installation via os package manager or pip * Run a second time to install via package manager * Check for EPEL if distro package requested. * Split dep lists to avoid installing build deps when using distro pkg Co-authored-by: Stefan Morgenthaler <dev@morgenthaler.at> Co-authored-by: Manu <manu@snapdragon.cc>
This commit is contained in:
parent
e34f9311d8
commit
981d4f9072
@ -87,7 +87,8 @@ $ git clone https://github.com/borgbase/ansible-role-borgbackup.git roles/ansibl
|
|||||||
- `ssh_key_file`: Path to a private ssh key file (default is `.ssh/id_ed25519`). It generates a ed25519 key if the file doesn't exist yet.
|
- `ssh_key_file`: Path to a private ssh key file (default is `.ssh/id_ed25519`). It generates a ed25519 key if the file doesn't exist yet.
|
||||||
- `borg_version`: Force a specific borg version to be installed
|
- `borg_version`: Force a specific borg version to be installed
|
||||||
- `borgmatic_version`: Force a specific borgmatic version to be installed
|
- `borgmatic_version`: Force a specific borgmatic version to be installed
|
||||||
|
- `borg_install_method`: By default `pip` is used to install borgmatic. To install via your distributions package manager set this to `package` and (if needed) overwrite the `borg_distro_packages` variable to contain your distributions package names required to install borgmatic. Note that many distributions ship outdated versions of borgbackup and borgmatic; use at your own risk.
|
||||||
|
- `borg_distro_packages`: contains the names of distributions packages for `borg(backup)` and `borgmatic`, only used if `borg_install_method` is set to `package`.
|
||||||
|
|
||||||
## Contributing
|
## Contributing
|
||||||
|
|
||||||
|
@ -35,7 +35,6 @@ borgmatic_cron_minute: "{{ 59 | random(seed=inventory_hostname) }}"
|
|||||||
borgmatic_cron_checks_day: "{{ range(1, 28) | random(seed=inventory_hostname) }}"
|
borgmatic_cron_checks_day: "{{ range(1, 28) | random(seed=inventory_hostname) }}"
|
||||||
borgmatic_cron_checks_hour: "{{ range(9, 24) | random(seed=inventory_hostname) }}"
|
borgmatic_cron_checks_hour: "{{ range(9, 24) | random(seed=inventory_hostname) }}"
|
||||||
borgmatic_cron_checks_minute: "{{ 59 | random(seed=inventory_hostname) }}"
|
borgmatic_cron_checks_minute: "{{ 59 | random(seed=inventory_hostname) }}"
|
||||||
|
|
||||||
|
|
||||||
borg_version: false
|
borg_version: false
|
||||||
borgmatic_version: false
|
borgmatic_version: false
|
||||||
|
borg_install_method: pip
|
||||||
|
@ -14,10 +14,10 @@ ENV {{ var }} {{ value }}
|
|||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
RUN if [ $(command -v apt-get) ]; then apt-get update && apt-get install -y python3 sudo bash ca-certificates iproute2 python3-apt aptitude && apt-get clean; \
|
RUN if [ $(command -v apt-get) ]; then apt-get update && apt-get install -y python3 python3-pip sudo bash ca-certificates iproute2 python3-apt aptitude && apt-get clean; \
|
||||||
elif [ $(command -v dnf) ]; then dnf makecache && dnf --assumeyes install /usr/bin/python3 /usr/bin/python3-config /usr/bin/dnf-3 sudo bash iproute && dnf clean all; \
|
elif [ $(command -v dnf) ]; then dnf makecache && dnf --assumeyes install /usr/bin/python3 /usr/bin/python3-config /usr/bin/dnf-3 sudo bash iproute && dnf clean all; \
|
||||||
elif [ $(command -v yum) ]; then yum makecache fast && yum install -y /usr/bin/python /usr/bin/python2-config sudo yum-plugin-ovl bash iproute && sed -i 's/plugins=0/plugins=1/g' /etc/yum.conf && yum clean all; \
|
elif [ $(command -v yum) ]; then yum makecache fast && yum install -y /usr/bin/python /usr/bin/python2-config sudo yum-plugin-ovl bash iproute && sed -i 's/plugins=0/plugins=1/g' /etc/yum.conf && yum clean all; \
|
||||||
elif [ $(command -v zypper) ]; then zypper refresh && zypper install -y python sudo bash python-xml iproute2 && zypper clean -a; \
|
elif [ $(command -v zypper) ]; then zypper refresh && zypper install -y python sudo bash python-xml iproute2 && zypper clean -a; \
|
||||||
elif [ $(command -v apk) ]; then apk update && apk add --no-cache python sudo bash ca-certificates; \
|
elif [ $(command -v apk) ]; then apk update && apk add --no-cache python sudo bash ca-certificates; \
|
||||||
elif [ $(command -v pacman) ]; then pacman --noconfirm -Suy python sudo openssh; \
|
elif [ $(command -v pacman) ]; then pacman --noconfirm -Suy python python-pip sudo openssh; \
|
||||||
elif [ $(command -v xbps-install) ]; then xbps-install -Syu && xbps-install -y python sudo bash ca-certificates iproute2 && xbps-remove -O; fi
|
elif [ $(command -v xbps-install) ]; then xbps-install -Syu && xbps-install -y python sudo bash ca-certificates iproute2 && xbps-remove -O; fi
|
||||||
|
@ -38,6 +38,7 @@
|
|||||||
- name: users
|
- name: users
|
||||||
hostname: database1.example.org
|
hostname: database1.example.org
|
||||||
port: 5433
|
port: 5433
|
||||||
|
borg_install_method: pip
|
||||||
|
|
||||||
post_tasks:
|
post_tasks:
|
||||||
- name: Install yamllint for checking config file
|
- name: Install yamllint for checking config file
|
||||||
|
@ -1 +0,0 @@
|
|||||||
---
|
|
@ -1 +0,0 @@
|
|||||||
---
|
|
@ -1 +0,0 @@
|
|||||||
---
|
|
18
tasks/install_package.yml
Normal file
18
tasks/install_package.yml
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
---
|
||||||
|
- name: Check if EPEL repo is enabled, if installation from distro is requested
|
||||||
|
when: ansible_os_family == 'RedHat'
|
||||||
|
block:
|
||||||
|
- name: Get list of installed packages
|
||||||
|
ansible.builtin.package_facts:
|
||||||
|
manager: auto
|
||||||
|
- name: Ensure EPEL is enabled
|
||||||
|
ansible.builtin.assert:
|
||||||
|
that:
|
||||||
|
- "'epel-release' in ansible_facts.packages"
|
||||||
|
fail_msg: Need EPEL repo to install via distro package.
|
||||||
|
|
||||||
|
- name: Install borgmatic and borg via distribution package manager
|
||||||
|
package:
|
||||||
|
name: "{{ item }}"
|
||||||
|
state: present
|
||||||
|
loop: "{{ borg_distro_packages }}"
|
39
tasks/install_pip.yml
Normal file
39
tasks/install_pip.yml
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
---
|
||||||
|
- name: Install build dependencies
|
||||||
|
package:
|
||||||
|
name: "{{ borg_pip_packages }}"
|
||||||
|
state: present
|
||||||
|
|
||||||
|
- name: Create virtualenv for borg # noqa package-latest
|
||||||
|
pip:
|
||||||
|
name:
|
||||||
|
- pip
|
||||||
|
- setuptools
|
||||||
|
state: latest
|
||||||
|
virtualenv: /opt/borgmatic
|
||||||
|
virtualenv_command: "{{ python_bin }} -m venv"
|
||||||
|
|
||||||
|
- name: Install dependent Python Packages
|
||||||
|
pip:
|
||||||
|
name: "{{ borg_dependent_python_packages }}"
|
||||||
|
virtualenv: /opt/borgmatic
|
||||||
|
when: borg_dependent_python_packages is defined
|
||||||
|
|
||||||
|
- name: Install main Python Packages
|
||||||
|
pip:
|
||||||
|
name: "{{ item.name }}"
|
||||||
|
version: "{{ item.version | default(omit, true) }}"
|
||||||
|
virtualenv: /opt/borgmatic
|
||||||
|
when: borg_python_packages is defined
|
||||||
|
loop: "{{ borg_python_packages }}"
|
||||||
|
|
||||||
|
- name: Create borgmatic command in /usr/local/bin
|
||||||
|
copy:
|
||||||
|
content: |
|
||||||
|
#!/bin/bash
|
||||||
|
. /opt/borgmatic/bin/activate
|
||||||
|
borgmatic "$@"
|
||||||
|
dest: /usr/local/bin/borgmatic
|
||||||
|
owner: root
|
||||||
|
group: root
|
||||||
|
mode: "0755"
|
@ -16,50 +16,14 @@
|
|||||||
- "{{ ansible_os_family }}.yml"
|
- "{{ ansible_os_family }}.yml"
|
||||||
- "{{ ansible_lsb.id }}.yml"
|
- "{{ ansible_lsb.id }}.yml"
|
||||||
|
|
||||||
- name: Run OS-specific tasks
|
- name: Install general dependencies (cron and openssh)
|
||||||
include_tasks: "{{ item }}"
|
|
||||||
with_first_found:
|
|
||||||
- "{{ ansible_os_family }}-{{ ansible_distribution_major_version }}.yml"
|
|
||||||
- "{{ ansible_os_family }}.yml"
|
|
||||||
|
|
||||||
- name: Install required System Packages
|
|
||||||
package:
|
package:
|
||||||
name: "{{ borg_packages }}"
|
name: "{{ borg_dep_packages }}"
|
||||||
state: present
|
state: present
|
||||||
|
|
||||||
- name: Create virtualenv for borg # noqa package-latest
|
- name: Install Borg and Borgmatic
|
||||||
pip:
|
ansible.builtin.include_tasks:
|
||||||
name:
|
file: install_{{ borg_install_method }}.yml
|
||||||
- pip
|
|
||||||
- setuptools
|
|
||||||
state: latest
|
|
||||||
virtualenv: /opt/borgmatic
|
|
||||||
virtualenv_command: "{{ python_bin }} -m venv"
|
|
||||||
|
|
||||||
- name: Install dependent Python Packages
|
|
||||||
pip:
|
|
||||||
name: "{{ borg_dependent_python_packages }}"
|
|
||||||
virtualenv: /opt/borgmatic
|
|
||||||
when: borg_dependent_python_packages is defined
|
|
||||||
|
|
||||||
- name: Install main Python Packages
|
|
||||||
pip:
|
|
||||||
name: "{{ item.name }}"
|
|
||||||
version: "{{ item.version | default(omit, true) }}"
|
|
||||||
virtualenv: /opt/borgmatic
|
|
||||||
when: borg_python_packages is defined
|
|
||||||
loop: "{{ borg_python_packages }}"
|
|
||||||
|
|
||||||
- name: Create borgmatic command in /usr/local/bin
|
|
||||||
copy:
|
|
||||||
content: |
|
|
||||||
#!/bin/bash
|
|
||||||
. /opt/borgmatic/bin/activate
|
|
||||||
borgmatic "$@"
|
|
||||||
dest: /usr/local/bin/borgmatic
|
|
||||||
owner: root
|
|
||||||
group: root
|
|
||||||
mode: "0755"
|
|
||||||
|
|
||||||
- name: Ensure root has SSH key.
|
- name: Ensure root has SSH key.
|
||||||
user:
|
user:
|
||||||
|
@ -1,11 +1,17 @@
|
|||||||
---
|
---
|
||||||
borg_packages:
|
borg_dep_packages:
|
||||||
- cronie
|
- cronie
|
||||||
- gcc
|
|
||||||
- openssh
|
- openssh
|
||||||
|
|
||||||
|
borg_pip_packages:
|
||||||
|
- gcc
|
||||||
- pkgconfig
|
- pkgconfig
|
||||||
- python-pip
|
- python-pip
|
||||||
- python-setuptools
|
- python-setuptools
|
||||||
|
|
||||||
|
borg_distro_packages:
|
||||||
|
- borg
|
||||||
|
- borgmatic
|
||||||
|
|
||||||
python_bin: python3
|
python_bin: python3
|
||||||
pip_bin: pip3
|
pip_bin: pip3
|
||||||
|
@ -1,5 +1,9 @@
|
|||||||
---
|
---
|
||||||
borg_packages:
|
borg_dep_packages:
|
||||||
|
- openssh-client
|
||||||
|
- cron
|
||||||
|
|
||||||
|
borg_pip_packages:
|
||||||
- libssl-dev
|
- libssl-dev
|
||||||
- libacl1-dev
|
- libacl1-dev
|
||||||
- libacl1
|
- libacl1
|
||||||
@ -10,8 +14,10 @@ borg_packages:
|
|||||||
- python3-pkgconfig
|
- python3-pkgconfig
|
||||||
- python3-msgpack
|
- python3-msgpack
|
||||||
- python3-venv
|
- python3-venv
|
||||||
- openssh-client
|
|
||||||
- cron
|
borg_distro_packages:
|
||||||
|
- borgbackup
|
||||||
|
- borgmatic
|
||||||
|
|
||||||
python_bin: python3
|
python_bin: python3
|
||||||
pip_bin: pip3
|
pip_bin: pip3
|
||||||
|
@ -1,5 +1,9 @@
|
|||||||
---
|
---
|
||||||
borg_packages:
|
borg_dep_packages:
|
||||||
|
- cronie
|
||||||
|
- openssh-clients
|
||||||
|
|
||||||
|
borg_pip_packages:
|
||||||
- libacl-devel
|
- libacl-devel
|
||||||
- libacl
|
- libacl
|
||||||
- gcc
|
- gcc
|
||||||
@ -10,8 +14,10 @@ borg_packages:
|
|||||||
- python3-devel
|
- python3-devel
|
||||||
- python3-setuptools
|
- python3-setuptools
|
||||||
- python3-Cython
|
- python3-Cython
|
||||||
- openssh-clients
|
|
||||||
- cronie
|
borg_distro_packages:
|
||||||
|
- borgbackup
|
||||||
|
- borgmatic
|
||||||
|
|
||||||
python_bin: python3
|
python_bin: python3
|
||||||
pip_bin: pip3
|
pip_bin: pip3
|
||||||
|
@ -1,8 +1,23 @@
|
|||||||
---
|
---
|
||||||
borg_packages:
|
borg_dep_packages:
|
||||||
- borgmatic
|
|
||||||
- openssh
|
- openssh
|
||||||
- cronie
|
- cronie
|
||||||
|
|
||||||
|
borg_pip_packages: # untested
|
||||||
|
- libssl-dev
|
||||||
|
- libacl1-dev
|
||||||
|
- libacl1
|
||||||
|
- build-essential
|
||||||
|
- python3-setuptools
|
||||||
|
- python3-dev
|
||||||
|
- python3-pip
|
||||||
|
- python3-pkgconfig
|
||||||
|
- python3-msgpack
|
||||||
|
- python3-venv
|
||||||
|
|
||||||
|
borg_distro_packages:
|
||||||
|
- borg
|
||||||
|
- borgmatic
|
||||||
|
|
||||||
python_bin: python3
|
python_bin: python3
|
||||||
pip_bin: pip3
|
pip_bin: pip3
|
||||||
|
@ -1,5 +1,9 @@
|
|||||||
---
|
---
|
||||||
borg_packages:
|
borg_dep_packages:
|
||||||
|
- openssh-clients
|
||||||
|
- cronie
|
||||||
|
|
||||||
|
borg_pip_packages:
|
||||||
- libacl-devel
|
- libacl-devel
|
||||||
- libacl
|
- libacl
|
||||||
- gcc
|
- gcc
|
||||||
@ -10,8 +14,10 @@ borg_packages:
|
|||||||
- python3-devel
|
- python3-devel
|
||||||
- python3-setuptools
|
- python3-setuptools
|
||||||
- python3-virtualenv
|
- python3-virtualenv
|
||||||
- openssh-clients
|
|
||||||
- cronie
|
borg_distro_packages:
|
||||||
|
- borgbackup
|
||||||
|
- borgmatic
|
||||||
|
|
||||||
python_bin: python3
|
python_bin: python3
|
||||||
pip_bin: pip3
|
pip_bin: pip3
|
||||||
|
@ -1,5 +1,9 @@
|
|||||||
---
|
---
|
||||||
borg_packages:
|
borg_dep_packages:
|
||||||
|
- cronie
|
||||||
|
- openssh-clients
|
||||||
|
|
||||||
|
borg_pip_packages:
|
||||||
- libacl-devel
|
- libacl-devel
|
||||||
- libacl
|
- libacl
|
||||||
- gcc
|
- gcc
|
||||||
@ -10,8 +14,10 @@ borg_packages:
|
|||||||
- python3-devel
|
- python3-devel
|
||||||
- python3-setuptools
|
- python3-setuptools
|
||||||
# - python3-virtualenv
|
# - python3-virtualenv
|
||||||
- openssh-clients
|
|
||||||
- cronie
|
borg_distro_packages:
|
||||||
|
- borgbackup
|
||||||
|
- borgmatic
|
||||||
|
|
||||||
python_bin: python3
|
python_bin: python3
|
||||||
pip_bin: pip3
|
pip_bin: pip3
|
||||||
|
@ -1,5 +1,9 @@
|
|||||||
---
|
---
|
||||||
borg_packages:
|
borg_dep_packages:
|
||||||
|
- cronie
|
||||||
|
- openssh-clients
|
||||||
|
|
||||||
|
borg_pip_packages:
|
||||||
- libacl-devel
|
- libacl-devel
|
||||||
- libacl
|
- libacl
|
||||||
- gcc
|
- gcc
|
||||||
@ -9,8 +13,10 @@ borg_packages:
|
|||||||
- python36-wheel
|
- python36-wheel
|
||||||
- python36-devel
|
- python36-devel
|
||||||
- python-setuptools
|
- python-setuptools
|
||||||
- openssh-clients
|
|
||||||
- cronie
|
borg_distro_packages:
|
||||||
|
- borgbackup
|
||||||
|
- borgmatic
|
||||||
|
|
||||||
python_bin: python3
|
python_bin: python3
|
||||||
pip_bin: pip3
|
pip_bin: pip3
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
borg_dependent_python_packages:
|
borg_dependent_python_packages:
|
||||||
- cython
|
- cython
|
||||||
- pkgconfig
|
- pkgconfig
|
||||||
|
|
||||||
borg_python_packages:
|
borg_python_packages:
|
||||||
- name: borgbackup
|
- name: borgbackup
|
||||||
version: "{{ borg_version }}"
|
version: "{{ borg_version }}"
|
||||||
|
Loading…
Reference in New Issue
Block a user