[PATCH v2 4/8] nfsd_add_export: fix become method for filesystem formatting

Chuck Lever <[email protected]> Fri, 3 Oct 2025 16:19:52 -0400
Newsgroups dev.linux.lists.kdevops
Message-ID <[email protected]>
From: Luis Chamberlain <[email protected]>

The filesystem module was unable to find mkfs.xfs when using
'become_flags: "su - -c"' which changes the environment.
Change to use standard 'become_method: sudo' to preserve
the PATH and allow the module to find the mkfs.xfs executable.

Generated-by: Claude AI
Signed-off-by: Luis Chamberlain <[email protected]>
Signed-off-by: Chuck Lever <[email protected]>
---
 playbooks/roles/nfsd_add_export/tasks/storage/local.yml | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/playbooks/roles/nfsd_add_export/tasks/storage/local.yml b/playbooks/roles/nfsd_add_export/tasks/storage/local.yml
index c366a13ff546..aaaf1de17993 100644
--- a/playbooks/roles/nfsd_add_export/tasks/storage/local.yml
+++ b/playbooks/roles/nfsd_add_export/tasks/storage/local.yml
@@ -11,8 +11,7 @@
 
 - name: Format new volume for {{ export_fstype }}
   become: true
-  become_flags: "su - -c"
-  become_method: ansible.builtin.sudo
+  become_method: sudo
   delegate_to: "{{ server_host }}"
   community.general.filesystem:
     fstype: "{{ export_fstype }}"
-- 
2.51.0