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

849 views
Skip to first unread message

Simon Hryszko

unread,
Aug 15, 2023, 10:11:21 AM8/15/23
to Ansible Project
Hey,

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

- I have bootstrap role 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 ansible.cfg file

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


Thanks in advance!
Simon

Brian Coca

unread,
Aug 15, 2023, 10:35:25 AM8/15/23
to ansible...@googlegroups.com
An example and the -vvv output when hitting the issue might be
helpful for other to diagnose your issue.

--
----------
Brian Coca

Simon Hryszko

unread,
Aug 15, 2023, 10:40:32 AM8/15/23
to Ansible Project
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


Thanks!

Brian Coca

unread,
Aug 15, 2023, 10:47:55 AM8/15/23
to ansible...@googlegroups.com
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).

----------
Brian Coca

Simon Hryszko

unread,
Aug 15, 2023, 11:17:25 AM8/15/23
to Ansible Project
Yeah, that was it!

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


Thanks soo much!
Reply all
Reply to author
Forward
0 new messages