nokia / ansible-networking-collections

BSD 3-Clause "New" or "Revised" License
39 stars 17 forks source link

Automatic revert time-out when subscribers are active #14

Open BartMertens opened 3 years ago

BartMertens commented 3 years ago

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...

lab01# admin rollback revert latest-rb    
Restoring rollback configuration cf3:\rollback\lab01.rb
Processing current config... 2.150 s
Processing "cf3:\rollback\lab01.rb"... 1.430 s
WARNING: CLI There are active subscriber hosts and/or dhcp lease states present in the system. The revert might fail if it attempts to make certain configuration changes that are associated with these hosts. It is highly recommended you create a rollback checkpoint before attempting this revert.
Do you want to continue (y/n)? n
Finished in 6.340 s
MINOR: CLI Rollback revert failed.
hansthienpondt commented 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
BartMertens commented 3 years ago

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

wisotzky commented 3 years ago

@BartMertens, need to have a deeper look on how to fix it... Is there any "force" option to skip over this dialogue?

BartMertens commented 3 years ago

Hi, as far as we can see in the SROS cli, there is no way to set "dialogue off" mode ...

JMichaud22 commented 3 years ago

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

BartMertens commented 3 years ago

Hi, as a test, I added this 'now' keyword on line 158 & 174, and this seems to do the trick...

cheers Bart

wisotzky commented 3 years ago

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.