---
- name: Clone rbenv
become: yes
git:
repo: 'https://github.com/rbenv/rbenv.git'
dest: /home/mastodon/.rbenv
works just fine
---
- name: Clone rbenv
become: yes
become_user: mastodon
git:
repo: 'https://github.com/rbenv/rbenv.git'
dest: /home/mastodon/.rbenv
doesn't work, error is 'FAILED! => {"msg": "Incorrect sudo password"}'
ansible_become_pass is set to ansible_user's sudo password
Ansible version: 2.15.3
OS: OpenSUSE
I've tried setting ansible_method, ansible_exe. I expect privilege escalation to make the command run as 'become_user'.
Looks like my issue was with sudoers.
Adding:
- name: Update sudoers
become: yes
community.general.sudoers:
name: ansible-do-as-mastodon
state: present
user: ansible
runas: mastodon
commands: ALL
resolved the issue