[PATCH 8/8] gen_hosts: drop sudo become on inventory owner refresh
Daniel Gomez <[email protected]> Thu, 23 Apr 2026 00:16:49 +0200
| Newsgroups | dev.linux.lists.kdevops |
|---|---|
| Message-ID | <[email protected]> |
From: Daniel Gomez <[email protected]> The inventory file is written by the same controller-side play that later refreshes its owner and group, and the refresh task sets owner to the current user and group to the current user's primary group - i.e. it chowns the file to its own owner. The task nevertheless wrapped that no-op in become_method: sudo + become_flags: "su - -c", and that combination fails at sudo invocation time with: /bin/sh: line 1: root: command not found The failure was masked by the task being guarded on the inventory file already existing, so it never fired on a freshly rendered tree. Drop the become block. The chown runs under the user the file already belongs to, and the gen_hosts role no longer depends on passwordless sudo on the control node. Generated-by: Claude AI Signed-off-by: Daniel Gomez <[email protected]> --- playbooks/roles/gen_hosts/tasks/main.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/playbooks/roles/gen_hosts/tasks/main.yml b/playbooks/roles/gen_hosts/tasks/main.yml index 0d67e49f..5e5acac0 100644 --- a/playbooks/roles/gen_hosts/tasks/main.yml +++ b/playbooks/roles/gen_hosts/tasks/main.yml @@ -37,9 +37,6 @@ register: kdevops_hosts_dest - name: Ensure proper permission on the inventory file - become: true - become_flags: "su - -c" - become_method: sudo ansible.builtin.file: path: "{{ ansible_cfg_inventory }}" owner: "{{ my_user.stdout }}" -- 2.53.0