# ansible does require sudo password (even when key is set up)

**URL:** <https://forum.ansible.com/t/ansible-does-require-sudo-password-even-when-key-is-set-up/38335>\
**Category:** Ansible Project\
**Created:** [August 15, 2023, 2:11pm UTC](https://forum.ansible.com/t/ansible-does-require-sudo-password-even-when-key-is-set-up/38335 "2023-08-15T14:11:21Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Simon\_Hryszko](https://avatars.discourse-cdn.com/v4/letter/s/b9e5f3/32.png) [@Simon\_Hryszko](https://forum.ansible.com/u/Simon_Hryszko)\
**Post date:** [August 15, 2023, 2:11pm UTC](https://forum.ansible.com/t/ansible-does-require-sudo-password-even-when-key-is-set-up/38335/1 "2023-08-15T14:11:21Z")

</div>

Hey,

I am new with Ansible, trying to set up Ansible, so it won’t require password, so

- I have [bootstrap role](https://github.com/SimonHryszko/IaC/blob/master/roles/bootstrap/tasks/main.yml) what after success run should let Ansible run any action without password

- When run Ansible it throws error ‘sudo: a password is required’

- I can log in manually and run command like `sudo -l` or `sudo echo work` without password prompt

- when add `--ask-become-pass` work fine (with typing manually, pass ofc)

- I ask Ansible to use username ‘groovy’ see [here](https://github.com/SimonHryszko/IaC/blob/master/ansible.cfg#L4) ansible.cfg file

I believe there is misconception or stupid bug, but cannot figure out myself

Link to IaC repo: [https://github.com/SimonHryszko/iac](https://github.com/SimonHryszko/iac)

Thanks in advance!  
Simon

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/ansible/original/1X/1882d9a01da5d8996a862359b0913cc568a39b84.svg) [@system](https://forum.ansible.com/u/system)\
**Post date:** [August 15, 2023, 2:34pm UTC](https://forum.ansible.com/t/ansible-does-require-sudo-password-even-when-key-is-set-up/38335/2 "2023-08-15T14:34:51Z")

</div>

An example and the -vvv output when hitting the issue might be  
helpful for other to diagnose your issue.

---

<div class="post-metadata">

**Author:** ![Simon\_Hryszko](https://avatars.discourse-cdn.com/v4/letter/s/b9e5f3/32.png) [@Simon\_Hryszko](https://forum.ansible.com/u/Simon_Hryszko)\
**Post date:** [August 15, 2023, 2:40pm UTC](https://forum.ansible.com/t/ansible-does-require-sudo-password-even-when-key-is-set-up/38335/3 "2023-08-15T14:40:31Z")

</div>

Sure, here is output, but what you meant via ‘example’

output of `ansible-playbook site.yml --limit=precision --tags=test -vvv`: [https://termbin.com/3w3f](https://termbin.com/3w3f)

Thanks!

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/ansible/original/1X/1882d9a01da5d8996a862359b0913cc568a39b84.svg) [@system](https://forum.ansible.com/u/system)\
**Post date:** [August 15, 2023, 2:47pm UTC](https://forum.ansible.com/t/ansible-does-require-sudo-password-even-when-key-is-set-up/38335/4 "2023-08-15T14:47:17Z")

</div>

You are connecting as `simon`, not `groovy`, which might explain the  
password requirement for sudo.

This is your config file /home/simon/Documents/IaC/ansible.cfg, make  
sure the setting is correct (ansible-config dump --only-changed should  
help with that).

---

<div class="post-metadata">

**Author:** ![Simon\_Hryszko](https://avatars.discourse-cdn.com/v4/letter/s/b9e5f3/32.png) [@Simon\_Hryszko](https://forum.ansible.com/u/Simon_Hryszko)\
**Post date:** [August 15, 2023, 3:17pm UTC](https://forum.ansible.com/t/ansible-does-require-sudo-password-even-when-key-is-set-up/38335/5 "2023-08-15T15:17:25Z")

</div>

Yeah, that was it!

I had `ansible_connection=local` so why it used `simon` user actually,

Thanks soo much!
