Open BartMertens opened 3 years ago
Can you share the ansible playbook task you've tried to execute? When expecting a prompt, the playbook should look like this:
- name: rollback config
cli_command:
command: admin rollback revert latest-rb
prompt:
- "Do you want to continue (y/n)?"
answer:
- 'y'
register: output6
Hi Hans,
thank you for your reply. The thing is, that it's the automatic rollback inside the Ansible scripts is that's being triggered. It was not a command that I send. Here is the original ansible playbook:
---
- hosts: lab_hosts
vars:
- ansible_network_os: nokia.sros.classic
vars_prompt:
- name: ansible_user
prompt: "Username"
private: no
- name: ansible_password
prompt: "Password"
connection: network_cli
gather_facts: No
collections:
- nokia.sros
tasks:
- name: Do a simple config
cli_config:
config: "{{ lookup('file', 'config_file') }}"
content of the config_file:
configure service customer 600 name "This Is A Test"
description "testing via Ansible"
exit
where we know that it gives an error because there is a 'create" missing.
when I try your suggestion:
- name: Do a simple config
cli_config:
config: "{{ lookup('file', 'config_file') }}"
prompt:
- "Do you want to continue (y/n)?"
answer:
- 'y'
register: output6
it fails:
TASK [Do a simple config] ******************************************************************************************************************************************************************************************************************
fatal: [labdevice]: FAILED! => {"ansible_facts": {"discovered_interpreter_python": "/usr/bin/python"}, "changed": false, "msg": "Unsupported parameters for (cli_config) module: answer, prompt, register Supported parameters include: backup, backup_options, commit, commit_comment, config, defaults, diff_ignore_lines, diff_match, diff_replace, multiline_delimiter, replace, rollback"}
Maybe I can do something with the parameters "commit" and or "rollback", but I don't see any documentation on what I can do with these options.
cheers Bart
@BartMertens, need to have a deeper look on how to fix it... Is there any "force" option to skip over this dialogue?
Hi, as far as we can see in the SROS cli, there is no way to set "dialogue off" mode ...
Hi, Yes, there is an option in the CLI - admin rollback revert latest-rb now
So maybe this is something that can be added in the call from your script Sven
Hi, as a test, I added this 'now' keyword on line 158 & 174, and this seems to do the trick...
cheers Bart
Sounds great... Let me merge that change in the coming days. But might be worth to add this to the docs, so people are aware that the rollback gets enforced.
When the config, in classic mode, needs to perform a rollback revert, on a system which has subscribers active, the rollback revert command gives a time-out:
fatal: [lab01]: FAILED! => {"ansible_facts": {"discovered_interpreter_python": "/usr/bin/python"}, "changed": false, "msg": "timeout value 30 seconds reached while trying to send command: admin rollback revert latest-rb"}
When you try a manual rollback revert on that system, you see that there is warning prompt. I believe this warning is not handled...