From ef7778e65f2c515a728f380f0d9d21ec5b232b92 Mon Sep 17 00:00:00 2001 From: Rich Megginson Date: Thu, 17 Aug 2023 10:52:50 -0600 Subject: [PATCH] fix: use stat.pw_name, stat.gr_name instead of owner, group Cause: The fields `stat.owner` and `stat.group` do not exist. Consequence: The crypttab was always being set to owner/group root. Fix: Use the correct fields `stat.pw_name` and `stat.gr_name`. Result: Owner and group of crypttab are preserved. See https://docs.ansible.com/ansible/2.9/modules/stat_module.html#return-stat/gr_name Signed-off-by: Rich Megginson --- tasks/main-blivet.yml | 4 ++-- .../tests_raid_volume_cleanup_nvme_generated.yml | 15 +++++++++++++++ .../tests_raid_volume_cleanup_scsi_generated.yml | 15 +++++++++++++++ 3 files changed, 32 insertions(+), 2 deletions(-) create mode 100644 tests/tests_raid_volume_cleanup_nvme_generated.yml create mode 100644 tests/tests_raid_volume_cleanup_scsi_generated.yml diff --git a/tasks/main-blivet.yml b/tasks/main-blivet.yml index 4f24cb63..fd0d60d4 100644 --- a/tasks/main-blivet.yml +++ b/tasks/main-blivet.yml @@ -195,8 +195,8 @@ state: "{{ entry.state }}" create: true mode: "{{ __storage_crypttab.stat.mode | d('0600') }}" - owner: "{{ __storage_crypttab.stat.owner | d('root') }}" - group: "{{ __storage_crypttab.stat.group | d('root') }}" + owner: "{{ __storage_crypttab.stat.pw_name | d('root') }}" + group: "{{ __storage_crypttab.stat.gr_name | d('root') }}" loop: "{{ blivet_output.crypts }}" loop_control: loop_var: entry diff --git a/tests/tests_raid_volume_cleanup_nvme_generated.yml b/tests/tests_raid_volume_cleanup_nvme_generated.yml new file mode 100644 index 00000000..08285ba0 --- /dev/null +++ b/tests/tests_raid_volume_cleanup_nvme_generated.yml @@ -0,0 +1,15 @@ +--- +# This file was generated by generate_tests.py +- name: Run test tests_raid_volume_cleanup.yml for nvme + hosts: all + tags: + - tests::nvme + tasks: + - name: Set disk interface for test + set_fact: + storage_test_use_interface: "nvme" + +- name: Import playbook + import_playbook: tests_raid_volume_cleanup.yml + tags: + - tests::nvme diff --git a/tests/tests_raid_volume_cleanup_scsi_generated.yml b/tests/tests_raid_volume_cleanup_scsi_generated.yml new file mode 100644 index 00000000..99334ba5 --- /dev/null +++ b/tests/tests_raid_volume_cleanup_scsi_generated.yml @@ -0,0 +1,15 @@ +--- +# This file was generated by generate_tests.py +- name: Run test tests_raid_volume_cleanup.yml for scsi + hosts: all + tags: + - tests::scsi + tasks: + - name: Set disk interface for test + set_fact: + storage_test_use_interface: "scsi" + +- name: Import playbook + import_playbook: tests_raid_volume_cleanup.yml + tags: + - tests::scsi