diff --git a/library/blivet.py b/library/blivet.py index bc2a537b..78eb5aef 100644 --- a/library/blivet.py +++ b/library/blivet.py @@ -1330,7 +1330,7 @@ def _destroy(self): class BlivetStratisVolume(BlivetVolume): - blivet_device_class = devices.StratisFilesystemDevice + blivet_device_class = devices.StratisFilesystemDevice if hasattr(devices, "StratisFilesystemDevice") else None def _update_from_device(self, param_name): if param_name == 'fs_type': @@ -1911,7 +1911,7 @@ def _look_up_device(self): class BlivetStratisPool(BlivetPool): - blivet_device_class = devices.StratisPoolDevice + blivet_device_class = devices.StratisPoolDevice if hasattr(devices, "StratisPoolDevice") else None def _type_check(self): return self._device.type == "stratis pool" diff --git a/tests/tests_stratis.yml b/tests/tests_stratis.yml index c41498ad..b68f02d2 100644 --- a/tests/tests_stratis.yml +++ b/tests/tests_stratis.yml @@ -24,92 +24,6 @@ ternary('packages_installed', '') }}" - service_facts - - name: Get unused disks - include_tasks: get_unused_disk.yml - vars: - min_size: "{{ volume_group_size }}" - disks_needed: 2 - - # stratisd is not started automatically and doesn't support DBus activation - # this will be covered by Blivet in the next build - - name: Start stratisd service - service: - name: stratisd - state: started - - - name: Create one Stratis pool with one volume - include_role: - name: linux-system-roles.storage - vars: - storage_pools: - - name: foo - disks: "{{ unused_disks }}" - type: stratis - volumes: - - name: test1 - size: "{{ volume_size }}" - mount_point: "{{ mount_location }}" - - - name: Verify role results - include_tasks: verify-role-results.yml - - - name: Repeat the previous invocation to verify idempotence - include_role: - name: linux-system-roles.storage - vars: - storage_pools: - - name: foo - disks: "{{ unused_disks }}" - type: stratis - volumes: - - name: test1 - size: "{{ volume_size }}" - mount_point: "{{ mount_location }}" - - - name: Verify role results - include_tasks: verify-role-results.yml - - - name: Add second filesystem to the pool - include_role: - name: linux-system-roles.storage - vars: - storage_pools: - - name: foo - disks: "{{ unused_disks }}" - type: stratis - volumes: - - name: test1 - size: "{{ volume_size }}" - mount_point: "{{ mount_location }}" - - name: test2 - size: "{{ volume_size }}" - mount_point: "{{ mount_location_2 }}" - - - name: Verify role results - include_tasks: verify-role-results.yml - - - name: Clean up - include_role: - name: linux-system-roles.storage - vars: - storage_pools: - - name: foo - disks: "{{ unused_disks }}" - type: stratis - state: absent - volumes: - - name: test1 - size: "{{ volume_size }}" - mount_point: "{{ mount_location }}" - state: absent - - name: test2 - size: "{{ volume_size }}" - mount_point: "{{ mount_location_2 }}" - state: absent - - - name: Verify role results - include_tasks: verify-role-results.yml - - name: Gather package facts package_facts: @@ -126,6 +40,9 @@ - name: Set distribution version set_fact: + is_rhel7: "{{ (ansible_facts.distribution == 'CentOS' or + ansible_facts.distribution == 'RedHat') and + ansible_facts.distribution_major_version == '7' }}" is_rhel9: "{{ (ansible_facts.distribution == 'CentOS' or ansible_facts.distribution == 'RedHat') and ansible_facts.distribution_major_version == '9' }}" @@ -134,12 +51,24 @@ ansible_facts.distribution_major_version == '10' }}" is_fedora: "{{ ansible_facts.distribution == 'Fedora' }}" - - name: Run test only if blivet supports this functionality - when: ((is_fedora and blivet_pkg_version is version("3.10.0-1", ">=")) or - (is_rhel10 and blivet_pkg_version is version("3.10.0-1", ">=")) or - (is_rhel9 and blivet_pkg_version is version("3.6.0-15", ">="))) + + - name: Completely skip this on RHEL/CentOS 7 where Stratis isn't supported + when: not is_rhel7 block: - - name: Create encrypted Stratis pool + - name: Get unused disks + include_tasks: get_unused_disk.yml + vars: + min_size: "{{ volume_group_size }}" + disks_needed: 2 + + # stratisd is not started automatically and doesn't support DBus activation + # this will be covered by Blivet in the next build + - name: Start stratisd service + service: + name: stratisd + state: started + + - name: Create one Stratis pool with one volume include_role: name: linux-system-roles.storage vars: @@ -147,8 +76,6 @@ - name: foo disks: "{{ unused_disks }}" type: stratis - encryption: true - encryption_password: yabbadabbadoo volumes: - name: test1 size: "{{ volume_size }}" @@ -165,8 +92,6 @@ - name: foo disks: "{{ unused_disks }}" type: stratis - encryption: true - encryption_password: yabbadabbadoo volumes: - name: test1 size: "{{ volume_size }}" @@ -175,7 +100,7 @@ - name: Verify role results include_tasks: verify-role-results.yml - - name: Clean up + - name: Add second filesystem to the pool include_role: name: linux-system-roles.storage vars: @@ -183,36 +108,13 @@ - name: foo disks: "{{ unused_disks }}" type: stratis - state: absent volumes: - name: test1 size: "{{ volume_size }}" mount_point: "{{ mount_location }}" - state: absent - - - name: Verify role results - include_tasks: verify-role-results.yml - - - name: Create one Stratis pool on one disk - include_role: - name: linux-system-roles.storage - vars: - storage_pools: - - name: foo - disks: "{{ unused_disks[0] }}" - type: stratis - - - name: Verify role results - include_tasks: verify-role-results.yml - - - name: Add the second disk to the pool - include_role: - name: linux-system-roles.storage - vars: - storage_pools: - - name: foo - disks: "{{ [unused_disks[0], unused_disks[1]] }}" - type: stratis + - name: test2 + size: "{{ volume_size }}" + mount_point: "{{ mount_location_2 }}" - name: Verify role results include_tasks: verify-role-results.yml @@ -231,43 +133,148 @@ size: "{{ volume_size }}" mount_point: "{{ mount_location }}" state: absent + - name: test2 + size: "{{ volume_size }}" + mount_point: "{{ mount_location_2 }}" + state: absent - name: Verify role results include_tasks: verify-role-results.yml - - name: Setup Tang server on localhost for testing - ansible.builtin.include_role: - name: fedora.linux_system_roles.nbde_server - vars: - nbde_server_manage_firewall: true - nbde_server_manage_selinux: true - nbde_server_port: 7500 - - - name: Create encrypted Stratis pool with Clevis/Tang - include_role: - name: linux-system-roles.storage - vars: - storage_pools: - - name: foo - disks: "{{ unused_disks[0] }}" - type: stratis - encryption: true - encryption_password: yabbadabbadoo - encryption_clevis_pin: tang - encryption_tang_url: localhost:7500 - - - name: Verify role results - include_tasks: verify-role-results.yml - - - name: Clean up - include_role: - name: linux-system-roles.storage - vars: - storage_pools: - - name: foo - disks: "{{ unused_disks[0] }}" - type: stratis - state: absent + - name: Run test only if blivet supports this functionality + when: ((is_fedora and blivet_pkg_version is version("3.10.0-1", ">=")) or + (is_rhel10 and blivet_pkg_version is version("3.10.0-1", ">=")) or + (is_rhel9 and blivet_pkg_version is version("3.6.0-15", ">="))) + block: + - name: Create encrypted Stratis pool + include_role: + name: linux-system-roles.storage + vars: + storage_pools: + - name: foo + disks: "{{ unused_disks }}" + type: stratis + encryption: true + encryption_password: yabbadabbadoo + volumes: + - name: test1 + size: "{{ volume_size }}" + mount_point: "{{ mount_location }}" + + - name: Verify role results + include_tasks: verify-role-results.yml + + - name: Repeat the previous invocation to verify idempotence + include_role: + name: linux-system-roles.storage + vars: + storage_pools: + - name: foo + disks: "{{ unused_disks }}" + type: stratis + encryption: true + encryption_password: yabbadabbadoo + volumes: + - name: test1 + size: "{{ volume_size }}" + mount_point: "{{ mount_location }}" + + - name: Verify role results + include_tasks: verify-role-results.yml + + - name: Clean up + include_role: + name: linux-system-roles.storage + vars: + storage_pools: + - name: foo + disks: "{{ unused_disks }}" + type: stratis + state: absent + volumes: + - name: test1 + size: "{{ volume_size }}" + mount_point: "{{ mount_location }}" + state: absent + + - name: Verify role results + include_tasks: verify-role-results.yml + + - name: Create one Stratis pool on one disk + include_role: + name: linux-system-roles.storage + vars: + storage_pools: + - name: foo + disks: "{{ unused_disks[0] }}" + type: stratis + + - name: Verify role results + include_tasks: verify-role-results.yml + + - name: Add the second disk to the pool + include_role: + name: linux-system-roles.storage + vars: + storage_pools: + - name: foo + disks: "{{ [unused_disks[0], unused_disks[1]] }}" + type: stratis + + - name: Verify role results + include_tasks: verify-role-results.yml + + - name: Clean up + include_role: + name: linux-system-roles.storage + vars: + storage_pools: + - name: foo + disks: "{{ unused_disks }}" + type: stratis + state: absent + volumes: + - name: test1 + size: "{{ volume_size }}" + mount_point: "{{ mount_location }}" + state: absent + + - name: Verify role results + include_tasks: verify-role-results.yml + + - name: Setup Tang server on localhost for testing + ansible.builtin.include_role: + name: fedora.linux_system_roles.nbde_server + vars: + nbde_server_manage_firewall: true + nbde_server_manage_selinux: true + nbde_server_port: 7500 + + - name: Create encrypted Stratis pool with Clevis/Tang + include_role: + name: linux-system-roles.storage + vars: + storage_pools: + - name: foo + disks: "{{ unused_disks[0] }}" + type: stratis + encryption: true + encryption_password: yabbadabbadoo + encryption_clevis_pin: tang + encryption_tang_url: localhost:7500 + + - name: Verify role results + include_tasks: verify-role-results.yml + + - name: Clean up + include_role: + name: linux-system-roles.storage + vars: + storage_pools: + - name: foo + disks: "{{ unused_disks[0] }}" + type: stratis + state: absent - - name: Verify role results - include_tasks: verify-role-results.yml + - name: Verify role results + include_tasks: verify-role-results.yml