Skip to content

Commit 4dc4779

Browse files
committed
fix: only install stratis if requested
Cause: stratis packages are always installed, and the daemon is always started, even if the user does not use stratis. Consequence: The system has unnecessary packages and services. To maintain a good security posture, no services should be installed and running if not required. Fix: Change the code so that stratis packages and services are deployed only if the user is managing stratis. Result: The storage role does not install unnecessary packages. Signed-off-by: Rich Megginson <rmeggins@redhat.com>
1 parent 9a8fc68 commit 4dc4779

9 files changed

Lines changed: 38 additions & 18 deletions

File tree

README-ostree.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ role cannot install packages. Instead, it will just verify that the necessary
66
packages and any other `/usr` files are pre-installed. The role will change the
77
package manager to one that is compatible with `rpm-ostree` systems.
88

9+
If you are not managing stratis pools or volumes, remove `stratisd` and
10+
`stratis-cli` from the ostree image package list generated from
11+
`.ostree/get_ostree_data.sh`.
12+
913
## Building
1014

1115
To build an ostree image for a particular operating system distribution and

tasks/main-blivet.yml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959

6060
- name: Make sure required packages are installed
6161
package:
62-
name: "{{ package_info.packages + extra_pkgs }}"
62+
name: "{{ package_info.packages + extra_pkgs + stratis_packages }}"
6363
state: present
6464
use: "{{ (__storage_is_ostree | d(false)) |
6565
ternary('ansible.posix.rhel_rpm_ostree', omit) }}"
@@ -72,6 +72,14 @@
7272
# into blivet, or made conditional
7373
extra_pkgs:
7474
- kpartx
75+
stratis_packages: "{{ __storage_manage_stratis | ternary(__storage_stratis_packages, []) }}"
76+
77+
- name: Ensure stratisd is running and enabled
78+
service:
79+
name: stratisd
80+
state: started
81+
enabled: true
82+
when: __storage_manage_stratis
7583

7684
- name: Manage storage devices and check for errors
7785
vars:

tests/tests_stratis.yml

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,15 @@
1818
vars:
1919
__storage_get_package_facts: true
2020
# From gather_facts only (safe before setup runs); mirrors is_rhel78 in setup.yml
21-
__storage_get_unused_disks: "{{ not (ansible_facts['os_family'] == 'RedHat' and (ansible_facts['distribution_major_version'] == '7' or ansible_facts['distribution_major_version'] == '8')) }}"
21+
__storage_get_unused_disks: "{{ not is_rhel78 }}"
22+
__sr_public: true
2223

2324
- name: Completely skip this on RHEL/CentOS 7 and 8 where Stratis isn't supported by blivet
2425
when: not is_rhel78
2526
block:
26-
# stratisd is not started automatically and doesn't support DBus activation
27-
# this will be covered by Blivet in the next build
28-
- name: Start stratisd service
29-
service:
30-
name: stratisd
31-
state: started
27+
- name: Ensure role will install stratis packages if needed
28+
set_fact:
29+
storage_skip_checks: "{{ storage_skip_checks | reject('match', '^packages_installed$') }}"
3230

3331
- name: One pool/volume test
3432
block:
@@ -246,3 +244,14 @@
246244

247245
- name: Verify role results - 12
248246
include_tasks: verify-role-results.yml
247+
always:
248+
- name: Ensure stratisd is stopped and disabled
249+
service:
250+
name: stratisd
251+
state: stopped
252+
enabled: false
253+
254+
- name: Remove stratis packages
255+
package:
256+
name: "{{ __storage_stratis_packages }}"
257+
state: absent

vars/Fedora.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@ blivet_package_list:
77
- libblockdev-lvm
88
- libblockdev-mdraid
99
- libblockdev-swap
10-
- stratisd
11-
- stratis-cli
1210
# XXX libblockdev-s390 is available only on s390 so just add 'libblockdev' everywhere
1311
# else, it is already brought in as dependency of blivet so it's just no-op here
1412
- "{{ 'libblockdev-s390' if ansible_facts['architecture'] == 's390x' else 'libblockdev' }}"

vars/OracleLinux_9.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@ blivet_package_list:
99
- vdo
1010
- kmod-kvdo
1111
- xfsprogs
12-
- stratisd
13-
- stratis-cli
1412
# XXX libblockdev-s390 is available only on s390 so just add 'libblockdev' everywhere
1513
# else, it is already brought in as dependency of blivet so it's just no-op here
1614
- "{{ 'libblockdev-s390' if ansible_facts['architecture'] == 's390x' else 'libblockdev' }}"

vars/RedHat_10.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@ blivet_package_list:
88
- libblockdev-mdraid
99
- libblockdev-swap
1010
- xfsprogs
11-
- stratisd
12-
- stratis-cli
1311
# XXX libblockdev-s390 is available only on s390 so just add 'libblockdev' everywhere
1412
# else, it is already brought in as dependency of blivet so it's just no-op here
1513
- "{{ 'libblockdev-s390' if ansible_facts['architecture'] == 's390x' else 'libblockdev' }}"

vars/RedHat_8.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@ blivet_package_list:
99
- vdo
1010
- kmod-kvdo
1111
- xfsprogs
12-
- stratisd
13-
- stratis-cli
1412
# XXX libblockdev-s390 is available only on s390 so just add 'libblockdev' everywhere
1513
# else, it is already brought in as dependency of blivet so it's just no-op here
1614
- "{{ 'libblockdev-s390' if ansible_facts['architecture'] == 's390x' else 'libblockdev' }}"

vars/RedHat_9.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@ blivet_package_list:
99
- vdo
1010
- kmod-kvdo
1111
- xfsprogs
12-
- stratisd
13-
- stratis-cli
1412
# XXX libblockdev-s390 is available only on s390 so just add 'libblockdev' everywhere
1513
# else, it is already brought in as dependency of blivet so it's just no-op here
1614
- "{{ 'libblockdev-s390' if ansible_facts['architecture'] == 's390x' else 'libblockdev' }}"

vars/main.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,15 @@ __storage_required_facts_subsets: "{{ ['!all', '!min', 'devices'] +
1818
__storage_uses_kmod_kvdo: "{{ __storage_is_rh_distro and
1919
ansible_facts['distribution_major_version'] | int < 10 }}"
2020

21+
__storage_stratis_packages:
22+
- stratisd
23+
- stratis-cli
24+
25+
# True when role variables request Stratis pool or volume management
26+
__storage_manage_stratis: "{{ (storage_pool_defaults.type | default('lvm')) == 'stratis' or (storage_volume_defaults.type | default('lvm')) == 'stratis' or
27+
(storage_pools | default([]) | selectattr('type', 'defined') | selectattr('type', 'match', '^stratis$') | list | length > 0) or
28+
(storage_volumes | default([]) | selectattr('type', 'defined') | selectattr('type', 'match', '^stratis$') | list | length > 0) }}"
29+
2130
# BEGIN - DO NOT EDIT THIS BLOCK - rh distros variables
2231
# Ansible distribution identifiers that the role treats like RHEL
2332
__storage_rh_distros:

0 commit comments

Comments
 (0)