Skip to content

Commit 85d17cf

Browse files
committed
Split dep lists to avoid installing build deps when using distro pkg
1 parent ed5db22 commit 85d17cf

18 files changed

+72
-56
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,8 @@ $ git clone https://github.com/borgbase/ansible-role-borgbackup.git roles/ansibl
8787
- `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.
8888
- `borg_version`: Force a specific borg version to be installed
8989
- `borgmatic_version`: Force a specific borgmatic version to be installed
90-
- `borgmatic_install_method`: By default `pip` is used to install borgmatic. To install via your distributions package manager set this to `package-manager` and overwrite the `borg_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.
91-
- `borg_system_packages`: contains the names of distributions packages for `borg(backup)` and `borgmatic`, only used if `borgmatic_install_method` is set to `package-manager`.
90+
- `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.
91+
- `borg_distro_packages`: contains the names of distributions packages for `borg(backup)` and `borgmatic`, only used if `borg_install_method` is set to `package`.
9292

9393
## Contributing
9494

defaults/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,4 @@ borgmatic_cron_checks_hour: "{{ range(9, 24) | random(seed=inventory_hostname) }
3737
borgmatic_cron_checks_minute: "{{ 59 | random(seed=inventory_hostname) }}"
3838
borg_version: false
3939
borgmatic_version: false
40-
borgmatic_install_method: pip
40+
borg_install_method: pip

molecule/default/Dockerfile.j2

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ ENV {{ var }} {{ value }}
1414
{% endfor %}
1515
{% endif %}
1616

17-
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; \
17+
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; \
1818
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; \
1919
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; \
2020
elif [ $(command -v zypper) ]; then zypper refresh && zypper install -y python sudo bash python-xml iproute2 && zypper clean -a; \
2121
elif [ $(command -v apk) ]; then apk update && apk add --no-cache python sudo bash ca-certificates; \
22-
elif [ $(command -v pacman) ]; then pacman --noconfirm -Suy python sudo openssh; \
22+
elif [ $(command -v pacman) ]; then pacman --noconfirm -Suy python python-pip sudo openssh; \
2323
elif [ $(command -v xbps-install) ]; then xbps-install -Syu && xbps-install -y python sudo bash ca-certificates iproute2 && xbps-remove -O; fi

molecule/default/converge.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
- name: users
3939
hostname: database1.example.org
4040
port: 5433
41+
borg_install_method: pip
4142

4243
post_tasks:
4344
- name: Install yamllint for checking config file

tasks/Archlinux.yml

Lines changed: 0 additions & 1 deletion
This file was deleted.

tasks/Debian.yml

Lines changed: 0 additions & 1 deletion
This file was deleted.

tasks/RedHat.yml renamed to tasks/install_package.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
- name: Check if EPEL repo is enabled, if installation from distro is requested
3-
when: borgmatic_install_method == 'package-manager'
3+
when: ansible_os_family == 'RedHat'
44
block:
55
- name: Get list of installed packages
66
ansible.builtin.package_facts:
@@ -10,3 +10,9 @@
1010
that:
1111
- "'epel-release' in ansible_facts.packages"
1212
fail_msg: Need EPEL repo to install via distro package.
13+
14+
- name: Install borgmatic and borg via distribution package manager
15+
package:
16+
name: "{{ item }}"
17+
state: present
18+
loop: "{{ borg_distro_packages }}"

tasks/install_pip.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
---
2+
- name: Install build dependencies
3+
package:
4+
name: "{{ borg_pip_packages }}"
5+
state: present
6+
27
- name: Create virtualenv for borg # noqa package-latest
38
pip:
49
name:

tasks/install_pkg.yml

Lines changed: 0 additions & 6 deletions
This file was deleted.

tasks/main.yml

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -16,26 +16,14 @@
1616
- "{{ ansible_os_family }}.yml"
1717
- "{{ ansible_lsb.id }}.yml"
1818

19-
- name: Run OS-specific tasks
20-
include_tasks: "{{ item }}"
21-
with_first_found:
22-
- "{{ ansible_os_family }}-{{ ansible_distribution_major_version }}.yml"
23-
- "{{ ansible_os_family }}.yml"
24-
25-
- name: Install required System Packages
19+
- name: Install general dependencies (cron and openssh)
2620
package:
27-
name: "{{ borg_packages }}"
21+
name: "{{ borg_dep_packages }}"
2822
state: present
2923

30-
- name: Install borgmatic via pip
31-
ansible.builtin.include_tasks:
32-
file: install_pip.yml
33-
when: borgmatic_install_method == 'pip'
34-
35-
- name: Install borgmatic via distribution package manager
24+
- name: Install Borg and Borgmatic
3625
ansible.builtin.include_tasks:
37-
file: install_pkg.yml
38-
when: borgmatic_install_method == 'package-manager'
26+
file: install_{{ borg_install_method }}.yml
3927

4028
- name: Ensure root has SSH key.
4129
user:

vars/Archlinux.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
---
2-
borg_packages:
2+
borg_dep_packages:
33
- cronie
4-
- gcc
54
- openssh
5+
6+
borg_pip_packages:
7+
- gcc
68
- pkgconfig
79
- python-pip
810
- python-setuptools
911

10-
borg_system_packages:
12+
borg_distro_packages:
1113
- borg
1214
- borgmatic
1315

vars/Debian.yml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
---
2-
borg_packages:
2+
borg_dep_packages:
3+
- openssh-client
4+
- cron
5+
6+
borg_pip_packages:
37
- libssl-dev
48
- libacl1-dev
59
- libacl1
@@ -10,10 +14,8 @@ borg_packages:
1014
- python3-pkgconfig
1115
- python3-msgpack
1216
- python3-venv
13-
- openssh-client
14-
- cron
1517

16-
borg_system_packages:
18+
borg_distro_packages:
1719
- borgbackup
1820
- borgmatic
1921

vars/Fedora.yml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
---
2-
borg_packages:
2+
borg_dep_packages:
3+
- cronie
4+
- openssh-clients
5+
6+
borg_pip_packages:
37
- libacl-devel
48
- libacl
59
- gcc
@@ -10,10 +14,8 @@ borg_packages:
1014
- python3-devel
1115
- python3-setuptools
1216
- python3-Cython
13-
- openssh-clients
14-
- cronie
1517

16-
borg_system_packages:
18+
borg_distro_packages:
1719
- borgbackup
1820
- borgmatic
1921

vars/ManjaroLinux.yml

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,21 @@
11
---
2-
borg_packages:
3-
- borgmatic
2+
borg_dep_packages:
43
- openssh
54
- cronie
65

7-
borg_system_packages:
6+
borg_pip_packages: # untested
7+
- libssl-dev
8+
- libacl1-dev
9+
- libacl1
10+
- build-essential
11+
- python3-setuptools
12+
- python3-dev
13+
- python3-pip
14+
- python3-pkgconfig
15+
- python3-msgpack
16+
- python3-venv
17+
18+
borg_distro_packages:
819
- borg
920
- borgmatic
1021

vars/RedHat-8.yml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
---
2-
borg_packages:
2+
borg_dep_packages:
3+
- openssh-clients
4+
- cronie
5+
6+
borg_pip_packages:
37
- libacl-devel
48
- libacl
59
- gcc
@@ -10,10 +14,8 @@ borg_packages:
1014
- python3-devel
1115
- python3-setuptools
1216
- python3-virtualenv
13-
- openssh-clients
14-
- cronie
1517

16-
borg_system_packages:
18+
borg_distro_packages:
1719
- borgbackup
1820
- borgmatic
1921

vars/RedHat-9.yml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
---
2-
borg_packages:
2+
borg_dep_packages:
3+
- cronie
4+
- openssh-clients
5+
6+
borg_pip_packages:
37
- libacl-devel
48
- libacl
59
- gcc
@@ -10,10 +14,8 @@ borg_packages:
1014
- python3-devel
1115
- python3-setuptools
1216
# - python3-virtualenv
13-
- openssh-clients
14-
- cronie
1517

16-
borg_system_packages:
18+
borg_distro_packages:
1719
- borgbackup
1820
- borgmatic
1921

vars/RedHat.yml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
---
2-
borg_packages:
2+
borg_dep_packages:
3+
- cronie
4+
- openssh-clients
5+
6+
borg_pip_packages:
37
- libacl-devel
48
- libacl
59
- gcc
@@ -9,10 +13,8 @@ borg_packages:
913
- python36-wheel
1014
- python36-devel
1115
- python-setuptools
12-
- openssh-clients
13-
- cronie
1416

15-
borg_system_packages:
17+
borg_distro_packages:
1618
- borgbackup
1719
- borgmatic
1820

vars/main.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
borg_dependent_python_packages:
33
- cython
44
- pkgconfig
5+
56
borg_python_packages:
67
- name: borgbackup
78
version: "{{ borg_version }}"

0 commit comments

Comments
 (0)