potential bug in eric_eccli module,

44 views
Skip to first unread message

Lucas Möller

unread,
Aug 15, 2019, 5:42:01 AM8/15/19
to Ansible Development
Hi all,

I am currently developing and checking out the eric_eccli module which has been merged to the devel build not long ago.
I am using the newest Ansible devel build

I got now a failure of a task with, as it seems, a normal command:

- name: save configuration to flash memory
eric_eccli_command:
commands:
- save configuration

even with
- y
or wait_for it fails due to command timeout.

From the terminal point of view it asks if the existing file should be overwritten.

On playbook execution, it fires the command waits until the timeout and fails.
Other commands work just fine, to mention all other commands do not require user input for (y/n).

This is a crucial feature for automating the upgrade and configuration management of the devices
Also the release download command for the device requests user input of (y/n)

Shell, command and raw modules do not solve the issue either.

Currently I see no way around this. Shall I report it as a bug on GitHub?
Or am I missing something?
It seems like the module is not capable of reacting to user input actions like (y/n)

To note: It fails on different devices due to the same issue.

Feedback is appreciated.

//Lucas

Ganesh Nalawade

unread,
Aug 16, 2019, 2:09:31 AM8/16/19
to Ansible Development

Try with below task. The prompt option is a regex value to match the expected terminal prompt after executing the command.

- name: save configuration to flash memory
eric_eccli_command:
commands:
      - command: save configuration
prompt: <regex to match prompt on terminal after command execution>
answer: 'y'

OR


- name: save configuration to flash memory
  cli_command:
command: save configuration
prompt: <regex to match prompt on terminal after command execution>
    answer: 'y'

https://docs.ansible.com/ansible/latest/modules/cli_command_module.html

Lucas Möller

unread,
Aug 16, 2019, 3:51:28 AM8/16/19
to Ansible Development
Thank you for the information.
eric_eccli_command has actually no option for prompts.
cli_command is then the way to go but there is another issue with that, which seems not to be related to the input in the playbook, but the output from the device:

    "changed": false,
    "invocation": {
        "module_args": {
            "answer": [
                "y"
            ],
            "check_all": false,
            "command": "save configuration",
            "newline": false,
            "prompt": [
                "Target file exists, overwrite? (y/n)"
            ],
            "sendonly": false
        }
    },
    "msg": "get() got an unexpected keyword argument 'newline'"

It does not matter what I enter as prompt and answer.
The actual response for the prompt from the device are two lines of output and in the second line the prompt has to be answered

Save to file: /flash/device_config.cfg
Target file exists, overwrite? (y/n) <answer should be here>

Though what I understand is that the error is not from the playbook syntax but from the parsing of the response.
Is there any option to avoid that error? Or to loop over the lines and answer on a match?

Lucas Möller

unread,
Aug 16, 2019, 4:31:43 AM8/16/19
to Ansible Development
Ok I have now checked the python code and commented the argument newline out (lib/ansible/modules/network/cli/cli_command.py: Line 147).

It is seems to work now.
But there is then an issue with the newline parameter on the type of network devices.

If anybody does not have a better solution or any information I might still be missing, I will open a feature request for prompts in eric_eccli and a bug report for cli_command and the newline parameter.

Thank you

Ganesh Nalawade

unread,
Aug 16, 2019, 5:35:50 AM8/16/19
to Lucas Möller, Ansible Development
Yes please raise a Github issue.
 Based on code eric_eccli_commnad module should support prompt when the value of “commands” option is list of dictionary. What is the error you see with eric_eccli_command module.


--
You received this message because you are subscribed to the Google Groups "Ansible Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-deve...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-devel/ca340d71-f319-473f-ad05-8f29af8ed992%40googlegroups.com.
--
Regards,
Ganesh B. Nalawade
Principal Engineer
Ansible by Red Hat
irc: ganeshrn

Lucas Möller

unread,
Aug 16, 2019, 5:43:00 AM8/16/19
to Ansible Development
Just that prompt, answer are noarguments of eric_eccli, here is the output:

    "changed": false,
    "invocation": {
        "module_args": {
            "answer": [
                "y"
            ],
            "commands": "save configuration",
            "prompt": [
                "(y/n)"
            ]
        }
    },
    "msg": "Unsupported parameters for (eric_eccli_command) module: answer, prompt Supported parameters include: commands, interval, match, retries, wait_for"


To unsubscribe from this group and stop receiving emails from it, send an email to ansibl...@googlegroups.com.

Ganesh Nalawade

unread,
Aug 16, 2019, 6:35:39 AM8/16/19
to Lucas Möller, Ansible Development
The task input seems to be wrong. Value of “commands” should be dictionary. Check the earlier mail for expected task input 

To unsubscribe from this group and stop receiving emails from it, send an email to ansible-deve...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-devel/f2d579cb-b16e-4b5f-80b7-443550f5c794%40googlegroups.com.

Lucas Möller

unread,
Aug 16, 2019, 7:16:15 AM8/16/19
to Ansible Development
Oh you're right, I have had a slightly different syntax.
It is working now as you told me, we can close down the discussion.

Thank you for helping me out.

Best regards

Lucas
Reply all
Reply to author
Forward
0 new messages