Ansible requiring sudo password when privilege escalation is not required

Viewed 18

Ansible is failing with sudo: a password is required when running ansible.builtin.file or ansible.builtin.find. The task does not require privilege elevation and is running under the user who owns the folder and files.

Attempted to set become=false at runtime, in ansible.cfg, in play and in task.

Only work around I found was to set become_user=myuserid for the unprivileged user and it no longer requested password for sudo.

Environment

Ubuntu 22.04.1 LTS
ansible [core 2.12.9]
python version = 3.10.6
ansible.netcommon 3.1.1
ansible.utils     2.6.1

NOTE: Replicating the issue have some dependency on the current SSH session to the Ansible server. The active shell/ssh session would continue to work but any new sessions would fail with the permission error (using the same non-privileged user).

Directory and playbook permissions

ahuff@ahuff-ansible:~/Device_Templates$ ls -lrt playbook.pb
-rw-rw-r-- 1 ahuff ahuff 2561 Aug 31 19:25 playbook.pb

ahuff@ahuff-ansible:~/Device_Templates$ ls -lrt scripts/
total 4
drwxrwx--- 13 ahuff ahuff 4096 Aug 11 17:04 enterprise
0 Answers
Related