Skip to content

Commit e8bf33e

Browse files
committed
Do not build snapraid on NAS host
Avoid installing build dependencies - reduce atack vector. Instead, depend on the snapraid installation file, .deb or .rpm being available in the 'files' dir The installation file can be built with serpro69/docker-apps-build
1 parent 02b8652 commit e8bf33e

File tree

5 files changed

+29
-55
lines changed

5 files changed

+29
-55
lines changed

metal/roles/storage/files/.gitkeep

Whitespace-only changes.

metal/roles/storage/tasks/setup_debian.yml

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,23 @@
1515
# nfs
1616
- nfs-kernel-server
1717
- nfs-common
18-
# snapraid build dependencies
19-
- build-essential
20-
- git
21-
- wget
2218
state: present
2319
update_cache: true
2420

2521
- name: Install mergerfs
2622
apt:
2723
deb: "{{ mergerfs_url_deb }}"
2824
state: present
25+
26+
- name: Copy snapraid .deb
27+
copy:
28+
src: files/snapraid_{{ snapraid_ver }}_{{ ansible_distribution_release }}.deb
29+
dest: /tmp/
30+
owner: root
31+
group: root
32+
mode: "0755"
33+
34+
- name: Install snapraid
35+
apt:
36+
deb: /tmp/snapraid_{{ snapraid_ver }}_{{ ansible_distribution_release }}.deb
37+
state: present

metal/roles/storage/tasks/setup_redhat.yml

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,18 @@
11
---
2-
- name: Download rpm
2+
- name: Download mergerfs rpm
33
get_url:
44
url: "{{ mergerfs_url_rpm }}"
55
dest: "/tmp/mergerfs-{{ mergerfs_ver }}.rpm"
66
mode: "0755"
77

8+
- name: Copy snapraid .rpm
9+
copy:
10+
src: files/snapraid_{{ snapraid_ver }}_{{ ansible_distribution_release }}.rpm
11+
dest: /tmp/
12+
owner: root
13+
group: root
14+
mode: "0755"
15+
816
- name: Set fastestmirror=True for dnf
917
lineinfile:
1018
path: /etc/dnf/dnf.conf
@@ -27,14 +35,14 @@
2735
- lm_sensors
2836
# nfs
2937
- nfs-utils
30-
# snapraid build dependencies
31-
- gcc
32-
- make
33-
- git
34-
- wget
3538
state: present
3639

3740
- name: Install mergerfs
3841
dnf:
39-
name: "/tmp/mergerfs-{{ mergerfs_ver }}.rpm"
42+
name: /tmp/mergerfs-{{ mergerfs_ver }}.rpm
43+
state: present
44+
45+
- name: Install snapraid
46+
dnf:
47+
name: "tmp/snapraid_{{ snapraid_ver }}_{{ ansible_distribution_release }}.rpm"
4048
state: present

metal/roles/storage/tasks/snapraid.yml

Lines changed: 0 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -9,43 +9,6 @@
99
fail_msg: "Cannot configure snapraid: parity_drives or data_drives is empty or undefined"
1010
success_msg: "Parity drives validation passed: {{ parity_drives | length }} parity drive(s), {{ data_drives | length }} data drive(s)"
1111

12-
- name: Create snapraid build directory
13-
tempfile:
14-
state: directory
15-
register: snapraid_build_dir
16-
17-
- name: Download snapraid source
18-
get_url:
19-
url: "{{ snapraid_url }}"
20-
dest: "{{ snapraid_build_dir.path }}/snapraid-{{ snapraid_version }}.tar.gz"
21-
mode: "0644"
22-
23-
- name: Extract snapraid source
24-
unarchive:
25-
src: "{{ snapraid_build_dir.path }}/snapraid-{{ snapraid_version }}.tar.gz"
26-
dest: "{{ snapraid_build_dir.path }}"
27-
remote_src: true
28-
creates: "{{ snapraid_build_dir.path }}/snapraid-{{ snapraid_version }}"
29-
30-
- name: Configure snapraid build
31-
command: ./configure
32-
args:
33-
chdir: "{{ snapraid_build_dir.path }}/snapraid-{{ snapraid_version }}"
34-
creates: "{{ snapraid_build_dir.path }}/snapraid-{{ snapraid_version }}/Makefile"
35-
36-
- name: Build snapraid
37-
command: make -j{{ ansible_processor_vcpus }}
38-
args:
39-
chdir: "{{ snapraid_build_dir.path }}/snapraid-{{ snapraid_version }}"
40-
creates: "{{ snapraid_build_dir.path }}/snapraid-{{ snapraid_version }}/snapraid"
41-
42-
- name: Install snapraid
43-
command: make install
44-
args:
45-
chdir: "{{ snapraid_build_dir.path }}/snapraid-{{ snapraid_version }}"
46-
creates: /usr/local/bin/snapraid
47-
become: true
48-
4912
- name: Create snapraid configuration
5013
template:
5114
src: snapraid.conf.j2
@@ -258,8 +221,3 @@
258221
enabled: "{{ snapraid_maintenance.content_backup_enabled }}"
259222
daemon_reload: true
260223
when: snapraid_maintenance.content_backup_enabled
261-
262-
- name: Cleanup build directory
263-
file:
264-
path: "{{ snapraid_build_dir.path }}"
265-
state: absent

metal/roles/storage/vars/main.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@ mergerfs_pkg_rpm: mergerfs-{{ mergerfs_ver }}.fc{{ ansible_distribution_release
66
mergerfs_url_deb: "{{ mergerfs_url_release }}/{{ mergerfs_pkg_deb}}"
77
mergerfs_url_rpm: "{{ mergerfs_url_release }}/{{ mergerfs_pkg_rpm }}"
88

9-
snapraid_version: "12.3"
10-
snapraid_url: "https://github.com/amadvance/snapraid/releases/download/v{{ snapraid_version }}/snapraid-{{ snapraid_version }}.tar.gz"
9+
snapraid_version: "13.0"
1110
snapraid_runner_url: "https://raw.githubusercontent.com/Chronial/snapraid-runner/master/snapraid-runner.py"
1211

1312
# Storage directories

0 commit comments

Comments
 (0)