-
Notifications
You must be signed in to change notification settings - Fork 232
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
bigip_command: doesnt fail on invalid command or when command returns non-zero exit code #2449
Comments
Mitigation action plugin that wraps bigip_command and adds error checking:
|
Hi @megamattzilla, Module is working as designed and provides the output of tmsh command so the result is the same as CLI. |
The modules runs the TMSH commands, but it should check that the command was successful before it reports the ansible task as status I think this module always showing as Running the same invalid command via TMSH shows an error message: root@(17-1-demo)(cfg-sync Standalone)(Active)(/Common)(tmos)# doesntexist
Syntax Error: unexpected argument "doesntexist"
root@(17-1-demo)(cfg-sync Standalone)(Active)(/Common)(tmos)# show ltm virtual doesnt exist
01020036:3: The requested Virtual Server (/Common/doesnt) was not found. TMSH shell shows the error when invalid commands are made- this module does not, so in that regard I think the module can be misleading. |
Hi @megamattzilla, The current output provided by the module is the same as the CLI as you can see below. PLAY [all] *****************************************************************************************************************************************
TASK [Gathering Facts] *****************************************************************************************************************************
ok: [10.1.1.9]
TASK [Run invalid command] *************************************************************************************************************************
ok: [10.1.1.9 -> localhost]
TASK [debug] ***************************************************************************************************************************************
ok: [10.1.1.9] => {
"msg": {
"changed": false,
"executed_commands": [
"tmsh -c \\\"show ltm virtual doesntexist\\\""
],
"failed": false,
"stdout": [
"01020036:3: The requested Virtual Server (/Common/doesntexist) was not found."
],
"stdout_lines": [
[
"01020036:3: The requested Virtual Server (/Common/doesntexist) was not found."
]
]
}
}
PLAY RECAP *****************************************************************************************************************************************
10.1.1.9 : ok=3 changed=0 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0 $ ansible-playbook -i hosts cmd2449-error.yml
PLAY [all] *****************************************************************************************************************************************
TASK [Gathering Facts] *****************************************************************************************************************************
ok: [10.1.1.9]
TASK [Run invalid command] *************************************************************************************************************************
[WARNING]: Using "write" commands is not idempotent. You should use a module that is specifically made for that. If such a module does not exist,
then please file a bug. The command in question is "doesnotexist..."
ok: [10.1.1.9 -> localhost]
TASK [debug] ***************************************************************************************************************************************
ok: [10.1.1.9] => {
"msg": {
"changed": false,
"executed_commands": [
"tmsh -c \\\"doesnotexist\\\""
],
"failed": false,
"stdout": [
"Syntax Error: unexpected argument \"doesnotexist\""
],
"stdout_lines": [
[
"Syntax Error: unexpected argument \"doesnotexist\""
]
],
"warnings": [
"Using \"write\" commands is not idempotent. You should use a module that is specifically made for that. If such a module does not exist, then please file a bug. The command in question is \"doesnotexist...\""
]
}
}
PLAY RECAP *****************************************************************************************************************************************
10.1.1.9 : ok=3 changed=0 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0 |
@pgouband so are you saying that this is a bug with the cli tool and that the bug report should be opened there? I think you would agree from an automation perspective (which Ansible is for), having a module that silently claims success when it fails is an issue! |
Hi @JonahBraun, That's not a bug. I understand your point of view about managing the error message provided by the command in different ways but when do we should provide only the output of call or modify the message to provide an error? |
COMPONENT NAME
bigip_command:
Environment
ANSIBLE VERSION
BIGIP VERSION
CONFIGURATION
defaults
OS / ENVIRONMENT
MacOS
SUMMARY
bigip_command: doesnt fail on invalid command or when command returns non zero exit code. It always shows as
ok
even if it runs an invalid command.STEPS TO REPRODUCE
Run playbook with invalid command:
EXPECTED RESULTS
Ansible task exits with failure.
ACTUAL RESULTS
Ansible task with invalid command or one that returns non-zero exit code as successful
ok
.The text was updated successfully, but these errors were encountered: