ansible-networking-collections
ansible-networking-collections copied to clipboard
playbook crash with md-cli config
Running this playbook leads to the crash. It looks like module cli_config is trying to run 'show system information' command from "configure private" mode. The correct syntax should be "/show system information". How do we fix that? The error is coming from capabilities code. When I comment out the code at ansible/netcommon/plugins/modules/cli_config.py", line 414 that gathers the capabilities, the playbook runs fine but the configuration is not getting applied. Config I am trying to push is simple port description in MD-CLI
/configure port 1/1/c5 description "TEST-P2-TO-XXXXXX-BB-CR2|1/1/C5|AE1|-|-|BB" /configure port 1/1/c5/1 description "TEST-P2-TO-XXXXXX-BB-CR2|1/1/C5|AE1|-|-|BB" /configure port 1/1/c6 description "TEST-P2-TO-XXXXXX-BB-CR2|1/1/C6|AE1|-|-|BB" /configure port 1/1/c6/1 description "TEST-P2-TO-XXXXXX-BB-CR2|1/1/C6|AE1|-|-|BB"
Running this directly on the router gives the same error
[pr:configure] A:user@hostname# show system information ^^^^ MINOR: MGMT_CORE #2201: Unknown element - 'show'
[pr:configure] A:user@hostname#
`---
-
name: Configure Nokia Router. hosts: nokia-hosts vars:
- ansible_network_os: nokia.sros.md
- ansible_user: "{{ SSH_USER }}"
- ansible_password: "{{ SSH_PASSWORD }}"
- ansible_command_timeout: 60
- ansible_python_interpreter: "/Users/nileshkhambal/Documents/myansible/bin/python3" connection: network_cli gather_facts: No
collections:
- nokia.sros
vars_files:
- prod-tacacs-vault.yaml
tasks:
-
name: switch to configure private mode cli_command: command: configure private
-
name: Fetch Configuration from File and apply it cli_config: config: "{{ lookup('file', devfilename)}}" commit: Yes vars: devfilename: "{{ inventory_hostname }}.set" register: configResult
-
name: Print Results debug: msg: | {{ configResult }}`
Here is the traceback
`The full traceback is:
Traceback (most recent call last):
File "/Users/nileshkhambal/.ansible/tmp/ansible-local-543012zf14w03/ansible-tmp-1636584763.1242611-54331-33671898253459/AnsiballZ_cli_config.py", line 102, in
[pr:configure]
A:user@xxxxxx-bb-cr1#
fatal: [xxxxxx-bb-cr1]: FAILED! => {
"changed": false,
"module_stderr": "Traceback (most recent call last):\n File "/Users/nileshkhambal/.ansible/tmp/ansible-local-543012zf14w03/ansible-tmp-1636584763.1242611-54331-33671898253459/AnsiballZ_cli_config.py", line 102, in
(myansible) ~/Documents/Work/NOKIA_Rollout/JPOSA3/lspconfig/remote/nokia: $ ansible --version ansible 2.10.1 config file = None configured module search path = ['/Users/nileshkhambal/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules'] ansible python module location = /Users/nileshkhambal/Documents/myansible/lib/python3.8/site-packages/ansible executable location = /Users/nileshkhambal/Documents/myansible/bin/ansible python version = 3.8.5 (v3.8.5:580fbb018f, Jul 20 2020, 12:11:27) [Clang 6.0 (clang-600.0.57)] (myansible) ~/Documents/Work/NOKIA_Rollout/JPOSA3/lspconfig/remote/nokia: $
Hello @nkhambal,
Did you resolve this problem already? Please look at the Nokia MD-CLI playbook example
The syntax your using isn't the same as in the Nokia MD-CLI sample as linked above your using: cli_command: command: configure private
vs the sample:
cli_config:
config: |
configure private
@nkhambal, the cli_config
should take care about changing into configuration mode and to finally commit the change. It must not be manually to ensure function.
Following playbook worked with one exception of "commit" tag. It commits even when it is set to "No". Is there an option to perform a commit "validate" and then "rollback" without actually committing the configuration?
---
- name: Configure Nokia.
hosts: nokia-hosts
serial: 1
vars:
- ansible_network_os: nokia.sros.md
- ansible_user: "{{ SSH_USER }}"
- ansible_password: "{{ SSH_PASSWORD }}"
- ansible_command_timeout: 60
- ansible_python_interpreter: "/Users/nileshkhambal/Documents/myansible/bin/python3"
connection: network_cli
gather_facts: No
collections:
- nokia.sros
vars_files:
- prod-tacacs-vault.yaml
tasks:
- name: Apply Configuration from File
cli_config:
config: "{{ lookup('file', devfilename)}}"
commit: No
vars:
devfilename: "{{ inventory_hostname }}.set"
register: configResult
- name: Print Results
debug:
msg: "{{ configResult.diff.split('\n') }}"
Replying the answer to my own query. To skip commit and discard candidate after validate, use "commit: False". Default is "commit: True". Following playbook worked. It fetches the template and generates the configuration (deleting mpls lsp configuration in this case) and pushes it via cli_config. Does compare, validate and then discards the configuration providing the diff.
NOTE: make sure you use "delete configure router" and not just "delete router" in the template. Later works with "configure private" but not "edit-config private" which is what the module uses to configure the device.
---
- name: Configure Nokia.
hosts: nokia-hosts
serial: 1
vars:
- ansible_network_os: nokia.sros.md
- ansible_user: "{{ SSH_USER }}"
- ansible_password: "{{ SSH_PASSWORD }}"
- ansible_command_timeout: 60
- ansible_python_interpreter: "/Users/nileshkhambal/Documents/myansible/bin/python3"
- remoteLsr: "{{ egress_lsr }}"
connection: network_cli
gather_facts: No
collections:
- nokia.sros
vars_files:
- prod-tacacs-vault.yaml
tasks:
- name: Apply Configuration from File
cli_config:
config: "{{ lookup('template', './delete_nokia_lsps_template.j2')}}"
commit: False
vars:
ingressLsr: "{{ inventory_hostname| upper }}"
egressLsr: "{{ remoteLsr| upper }}"
register: configResult
- name: Print Results
debug:
msg: "{{ configResult.diff.split('\n') }}"