question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

"sudo: a password is required" error with "local_action: file path={{ fetch_directory }} state=directory"

See original GitHub issue

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 https://github.com/ceph/ceph-ansible/blob/master/roles/ceph-mon/tasks/docker/create_configs.yml#L2:

 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

I don’t understand, become:false is used in this task.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

17reactions
colanscommented, Jul 30, 2019

become: false is the newer non-deprecated way to do it.

10reactions
debabratpcommented, May 11, 2017

Use sudo: no in you task instead.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Ansible: how to solve "sudo: a password is required" error?
The main issue is that for ansible task needs the password of 4 servers, so i did export ask sudo password and it...
Read more >
Ansible - "sudo: a password is required" [SOLVED] - ShellHacks
How to fix the "sudo: a password is required" error in Ansible while running the "ansible-playbook" command with "become: True".
Read more >
smb.conf - Samba.org
If no match is found, the requested section name is treated as a username and looked up in the local password file. If...
Read more >
Operations - Fabric documentation
local_path is the local file path where the downloaded file or files will be ... allows get to copy (using sudo) the remote...
Read more >
Ansible file Module Tutorial + Examples - TopTechSkills.com
name: modify permissions and properties of a directory (or create it if it doesn't exist) file: path: $HOME/test_directory/inner_test_directory state: ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found