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.
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>
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:
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)
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?
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.
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.