# "sudo: a password is required" error with "local\_action: file path={{ fetch\_directory }} state=directory"

**URL:** <https://forum.ansible.com/t/sudo-a-password-is-required-error-with-local-action-file-path-fetch-directory-state-directory/23179>\
**Category:** Ansible Project\
**Created:** [December 6, 2016, 10:33am UTC](https://forum.ansible.com/t/sudo-a-password-is-required-error-with-local-action-file-path-fetch-directory-state-directory/23179 "2016-12-06T10:33:56Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Stephane\_Klein1](https://avatars.discourse-cdn.com/v4/letter/s/ee7513/32.png) [@Stephane\_Klein1](https://forum.ansible.com/u/Stephane_Klein1)\
**Post date:** [December 6, 2016, 10:33am UTC](https://forum.ansible.com/t/sudo-a-password-is-required-error-with-local-action-file-path-fetch-directory-state-directory/23179/1 "2016-12-06T10:33:56Z")

</div>

Hi,

I have this error:

` TASK [ceph-mon : create a local fetch directory if it does not exist] ********** task path: /Users/stephane/projets/tech-angels/test_ceph/vagrant/roles/ceph-mon/tasks/docker/create_configs.yml:2 Using module file /usr/local/lib/python2.7/site-packages/ansible/modules/core/files/file.py <localhost> ESTABLISH LOCAL CONNECTION FOR USER: stephane <localhost> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo $HOME/.ansible/tmp/ansible-tmp-1481019912.14-221559219655965 `" && echo ansible-tmp-1481019912.14-221559219655965="` echo $HOME/.ansible/tmp/ansible-tmp-1481019912.14-221559219655965 `" ) && sleep 0' <localhost> PUT /var/folders/7v/bs1393w960b4_g1_2b5h9sf00000gn/T/tmpSVsFnm TO /Users/stephane/.ansible/tmp/ansible-tmp-1481019912.14-221559219655965/file.py <localhost> EXEC /bin/sh -c 'chmod u+x /Users/stephane/.ansible/tmp/ansible-tmp-1481019912.14-221559219655965/ /Users/stephane/.ansible/tmp/ansible-tmp-1481019912.14-221559219655965/file.py && sleep 0' <localhost> EXEC /bin/sh -c 'sudo -H -S -n -u root /bin/sh -c '"'"'echo BECOME-SUCCESS-drwxnaweihqdaahqciaxhgilzausrdhj; /usr/local/opt/python/bin/python2.7 /Users/stephane/.ansible/tmp/ansible-tmp-1481019912.14-221559219655965/file.py; rm -rf "/Users/stephane/.ansible/tmp/ansible-tmp-1481019912.14-221559219655965/" > /dev/null 2>&1'"'"' && sleep 0' fatal: [ceph-test-1 -> localhost]: FAILED! => { "changed": false, "failed": true, "invocation": { "module_name": "file" }, "module_stderr": "sudo: a password is required\n", "module_stdout": "", "msg": "MODULE FAILURE" } `

With this code:

`

- name: create a local fetch directory if it does not exist  
local\_action: file path={{ fetch\_directory }} state=directory  
changed\_when: false  
become: false  
run\_once: true  
when: cephx or generate\_fsid

`

Original source code is here: [https://github.com/ceph/ceph-ansible/blob/master/roles/ceph-mon/tasks/docker/create\_configs.yml#L2](https://github.com/ceph/ceph-ansible/blob/master/roles/ceph-mon/tasks/docker/create_configs.yml#L2)

Question: why if I have \*`become: false*` file action use sudo ?

Best regards,  
Stéphane

---

<div class="post-metadata">

**Author:** ![Stephane\_Klein1](https://avatars.discourse-cdn.com/v4/letter/s/ee7513/32.png) [@Stephane\_Klein1](https://forum.ansible.com/u/Stephane_Klein1)\
**Post date:** [December 6, 2016, 1:36pm UTC](https://forum.ansible.com/t/sudo-a-password-is-required-error-with-local-action-file-path-fetch-directory-state-directory/23179/2 "2016-12-06T13:36:36Z")

</div>

If I use:

`  
become\_user: stephane

`

It is working!

How can I configure Ansible to use always my current user when it execute `local_action` ?

---

<div class="post-metadata">

**Author:** ![Stephane\_Klein1](https://avatars.discourse-cdn.com/v4/letter/s/ee7513/32.png) [@Stephane\_Klein1](https://forum.ansible.com/u/Stephane_Klein1)\
**Post date:** [December 7, 2016, 9:10am UTC](https://forum.ansible.com/t/sudo-a-password-is-required-error-with-local-action-file-path-fetch-directory-state-directory/23179/3 "2016-12-07T09:10:40Z")

</div>

More information about this subject: Bug Report: local\_action execute command with sudo -u root instead my current user
