Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modules shell and command only output MODULE FAILURE on error #18846

Closed
dagwieers opened this issue Dec 7, 2016 · 1 comment · Fixed by #18875
Closed

Modules shell and command only output MODULE FAILURE on error #18846

dagwieers opened this issue Dec 7, 2016 · 1 comment · Fixed by #18875
Labels
affects_2.2 This issue/PR affects Ansible v2.2 bug This issue/PR relates to a bug.

Comments

@dagwieers
Copy link
Contributor

ISSUE TYPE
  • Bug Report
COMPONENT NAME

command / shell

ANSIBLE VERSION

v2.2

CONFIGURATION

hosts

problemhost ansible_host=127.0.0.1 ansible_python_interpreter=/foo/bar
OS / ENVIRONMENT

Any

SUMMARY

The shell and command modules do not provide any indication to what the error is, it only outputs MODULE FAILURE

STEPS TO REPRODUCE
[dag@moria ansible.testing]$ ansible problemhost -m setup 
problemhost | FAILED! => {
    "changed": false, 
    "failed": true, 
    "module_stderr": "/bin/sh: /foo/bar: No such file or directory\n", 
    "module_stdout": "", 
    "msg": "MODULE FAILURE"
}

[dag@moria ansible.testing]$ ansible problemhost -m command -a date
problemhost | FAILED | rc=0 >>
MODULE FAILURE
EXPECTED RESULTS
problemhost | FAILED! => {
    "changed": false, 
    "failed": true, 
    "module_stderr": "/bin/sh: /foo/bar: No such file or directory\n", 
    "module_stdout": "", 
    "msg": "MODULE FAILURE"
}
ACTUAL RESULTS
problemhost | FAILED | rc=0 >>
MODULE FAILURE

dagwieers added a commit to dagwieers/ansible that referenced this issue Dec 9, 2016
This fix ensures that if there are specific module errors (in our case
the python interpreter was not found) then command and shell returns a
proper error.

It also fixes a few other imperfections that we noticed during
troubleshooting:

- Return the real RC if it were available
- Improve a dictionary evaluation using .get()
- Return an RC of -1 if it is unknown (instead of returning 0)

This fixes ansible#18846
@ansibot ansibot added affects_2.2 This issue/PR affects Ansible v2.2 bug_report module This issue/PR relates to a module. and removed module This issue/PR relates to a module. plugin labels Dec 13, 2016
bcoca pushed a commit that referenced this issue Dec 17, 2016
This fix ensures that if there are specific module errors (in our case
the python interpreter was not found) then command and shell returns a
proper error.

It also fixes a few other imperfections that we noticed during
troubleshooting:

- Return the real RC if it were available
- Improve a dictionary evaluation using .get()
- Return an RC of -1 if it is unknown (instead of returning 0)

This fixes #18846
@ansibot ansibot added bug This issue/PR relates to a bug. and removed bug_report labels Mar 7, 2018
@namasivayamcse
Copy link

namasivayamcse commented Aug 1, 2018

I have face the same issue as below

Error

[ansible-user@ansiblemaster linux-ping]$ ansible centos -m ping

ansiblenode1 | FAILED! => {
"changed": false,
"module_stderr": "Shared connection to ansiblenode1 closed.\r\n",
"module_stdout": "sudo: a password is required\r\n",
"msg": "MODULE FAILURE",
"rc": 1
}

Resolution:
I have added below entry in /etc/sudoers on the Master node & client node.
ansible-user ALL=(ALL) NOPASSWD: ALL

Post addition of ansible user into the /etc/sudoers file issue got fixed.

Output
[ansible-user@ansiblemaster linux-ping]$ ansible centos -m ping
ansiblenode1 | SUCCESS => {
"changed": false,
"ping": "pong"
}

@ansible ansible locked and limited conversation to collaborators Apr 25, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
affects_2.2 This issue/PR affects Ansible v2.2 bug This issue/PR relates to a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants