Coder Social home page Coder Social logo

ansible-networking-collections's People

Contributors

csatarigergely avatar dmitry-sam avatar hansthienpondt avatar jbemmel avatar pszulczewski avatar wisotzky avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ansible-networking-collections's Issues

[Py3.8] dictionary keys changed during iteration.

Looks like the source of the issue starts here.

I believe the root issue ("dictionary keys changed during iteration") is Py3.8 specific and a temp dict needs to be created for iteration (rather than in-place changing an existing dict).

This applies to both Get and Set.

Output from run, using any xpath with a "list" in it, for example "provision-aps/provision-ap[mac=00:11:74:snip]":

ansible-playbook -i hosts SROS_gNMI_ConfigDemo.yml -vvv
...
The full traceback is:
  File "/tmp/ansible_gnmi_get_payload_cisd7fur/ansible_gnmi_get_payload.zip/ansible_collections/nokia/grpc/plugins/modules/gnmi_get.py", line 106, in main
  File "/tmp/ansible_gnmi_get_payload_cisd7fur/ansible_gnmi_get_payload.zip/ansible/module_utils/connection.py", line 185, in __rpc__
    raise ConnectionError(to_text(msg, errors='surrogate_then_replace'), code=code)
fatal: [192.168.2.2]: FAILED! => {
    "ansible_facts": {
        "discovered_interpreter_python": "/usr/bin/python3"
    },
    "changed": false,
    "code": -32603,
    "invocation": {
        "module_args": {
            "path": [
                "provision-aps/provision-ap[mac=*snip*]"
            ],
            "prefix": "/",
            "type": "ALL"
        }
    },
    "msg": "dictionary keys changed during iteration"
}

Usage of CONFIG in gNMI SetRequest()

Attempting a gNMI SetRequest operation, it looks like the SetRequest is using the CONFIG DataType from GetRequest.

For example, using these path and values in the example playbook:

  - name: Update Nodal Configuration (using gNMI SET)
    gnmi_config:
      update:
        - path: /provision-aps/provision-ap[mac=00:11:74:*snip*]/config/hostname
          val: lab-ap.example.com

I get the following traceback:

The full traceback is:
WARNING: The below traceback may *not* be related to the actual failure.
  File "/tmp/ansible_gnmi_config_payload_U0Did_/ansible_gnmi_config_payload.zip/ansible_collections/nokia/grpc/plugins/modules/gnmi_config.py", line 135, in main
  File "/tmp/ansible_gnmi_config_payload_U0Did_/ansible_gnmi_config_payload.zip/ansible/module_utils/connection.py", line 195, in __rpc__
    raise ConnectionError(to_text(msg, errors='surrogate_then_replace'), code=code)
fatal: [192.168.2.2]: FAILED! => {
    "changed": false,
    "code": -32603,
    "invocation": {
        "module_args": {
            "backup": false,
            "backup_options": null,
            "delete": null,
            "prefix": null,
            "replace": null,
            "update": [
                {
                    "path": "/provision-aps/provision-ap[mac=00:11:74:*snip*]/config/hostname",
                    "val": "lab-ap.example.com"
                }
            ]
        }
    },
    "msg": "<_InactiveRpcError of RPC that terminated with:\n\tstatus = StatusCode.UNIMPLEMENTED\n\tdetails = \"unsupported request type: CONFIG\"\n\tdebug_error_string = \"{\"created\":\"@1612416547.477349400\",\"description\":\"Error received from peer ipv4:192.168.2.2:8080\",\"file\":\"src/core/lib/surface/call.cc\",\"file_line\":1067,\"grpc_message\":\"unsupported request type: CONFIG\",\"grpc_status\":12}\"\n>"
}

If I remove "type=config" from here the "unsupported request type: CONFIG" error goes away. I am instead hitting another error, though that error may be completely unrelated (including that below in case it helps):

The full traceback is:
WARNING: The below traceback may *not* be related to the actual failure.
  File "/tmp/ansible_gnmi_config_payload_w6AewL/ansible_gnmi_config_payload.zip/ansible_collections/nokia/grpc/plugins/modules/gnmi_config.py", line 136, in main
  File "/tmp/ansible_gnmi_config_payload_w6AewL/ansible_gnmi_config_payload.zip/ansible/module_utils/connection.py", line 195, in __rpc__
    raise ConnectionError(to_text(msg, errors='surrogate_then_replace'), code=code)
fatal: [192.168.2.2]: FAILED! => {
    "changed": false,
    "code": -32603,
    "invocation": {
        "module_args": {
            "backup": false,
            "backup_options": null,
            "delete": null,
            "prefix": null,
            "replace": null,
            "update": [
                {
                    "path": "/provision-aps/provision-ap[mac=00:11:74:*snip*]/config/hostname",
                    "val": "lab-ap.example.com"
                }
            ]
        }
    },
    "msg": "Ansible gNMI plugin does not support encoding for value: {\"stringVal\": \"tester-05.foo.net\"}"
}

...where tester-05.foo.net is the hostname assigned to the leaf referenced above.

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
_ansiballz_main()
File "/Users/nileshkhambal/.ansible/tmp/ansible-local-543012zf14w03/ansible-tmp-1636584763.1242611-54331-33671898253459/AnsiballZ_cli_config.py", line 94, in _ansiballz_main
invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)
File "/Users/nileshkhambal/.ansible/tmp/ansible-local-543012zf14w03/ansible-tmp-1636584763.1242611-54331-33671898253459/AnsiballZ_cli_config.py", line 40, in invoke_module
runpy.run_module(mod_name='ansible_collections.ansible.netcommon.plugins.modules.cli_config', init_globals=None, run_name='main', alter_sys=True)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/runpy.py", line 207, in run_module
return _run_module_code(code, init_globals, run_name, mod_spec)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/runpy.py", line 97, in _run_module_code
_run_code(code, mod_globals, init_globals,
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/runpy.py", line 87, in _run_code
exec(code, run_globals)
File "/var/folders/1l/0fnzwtp91w7_hr34_7qtd55r0000gn/T/ansible_cli_config_payload_jtfni_53/ansible_cli_config_payload.zip/ansible_collections/ansible/netcommon/plugins/modules/cli_config.py", line 461, in
File "/var/folders/1l/0fnzwtp91w7_hr34_7qtd55r0000gn/T/ansible_cli_config_payload_jtfni_53/ansible_cli_config_payload.zip/ansible_collections/ansible/netcommon/plugins/modules/cli_config.py", line 414, in main
File "/var/folders/1l/0fnzwtp91w7_hr34_7qtd55r0000gn/T/ansible_cli_config_payload_jtfni_53/ansible_cli_config_payload.zip/ansible/module_utils/connection.py", line 195, in rpc
ansible.module_utils.connection.ConnectionError: show system information
^^^^
MINOR: MGMT_CORE #2201: Unknown element - 'show'

[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 \n _ansiballz_main()\n File "/Users/nileshkhambal/.ansible/tmp/ansible-local-543012zf14w03/ansible-tmp-1636584763.1242611-54331-33671898253459/AnsiballZ_cli_config.py", line 94, in _ansiballz_main\n invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)\n File "/Users/nileshkhambal/.ansible/tmp/ansible-local-543012zf14w03/ansible-tmp-1636584763.1242611-54331-33671898253459/AnsiballZ_cli_config.py", line 40, in invoke_module\n runpy.run_module(mod_name='ansible_collections.ansible.netcommon.plugins.modules.cli_config', init_globals=None, run_name='main', alter_sys=True)\n File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/runpy.py", line 207, in run_module\n return _run_module_code(code, init_globals, run_name, mod_spec)\n File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/runpy.py", line 97, in _run_module_code\n _run_code(code, mod_globals, init_globals,\n File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/runpy.py", line 87, in _run_code\n exec(code, run_globals)\n File "/var/folders/1l/0fnzwtp91w7_hr34_7qtd55r0000gn/T/ansible_cli_config_payload_jtfni_53/ansible_cli_config_payload.zip/ansible_collections/ansible/netcommon/plugins/modules/cli_config.py", line 461, in \n File "/var/folders/1l/0fnzwtp91w7_hr34_7qtd55r0000gn/T/ansible_cli_config_payload_jtfni_53/ansible_cli_config_payload.zip/ansible_collections/ansible/netcommon/plugins/modules/cli_config.py", line 414, in main\n File "/var/folders/1l/0fnzwtp91w7_hr34_7qtd55r0000gn/T/ansible_cli_config_payload_jtfni_53/ansible_cli_config_payload.zip/ansible/module_utils/connection.py", line 195, in rpc\nansible.module_utils.connection.ConnectionError: show system information\r\n ^^^^\r\nMINOR: MGMT_CORE #2201: Unknown element - 'show'\r\n\r\n[pr:configure]\r\nA:user@xxxxxx-bb-cr1# \n",
"module_stdout": "",
"msg": "MODULE FAILURE\nSee stdout/stderr for the exact error",
"rc": 1
}`

(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: $

Handling /file portion of the CLI possible?

@wisotzky

I might be missing the obvious here, but is there a way with the nokia.sros/nokia.sros.light plugin's to browse into the file tree? I have tried sending something like this but I suspect it is wanting to see the response of each individual command and never seeing std_out, so it just hangs until command timeout is triggered.

"/file\ncd cf3:\\images\\TiMOS-B-16.0.R10\ndir\n"

GRPC Connection error with newer dependencies

I am trying to use the grpc collection, but to no avail.

protobuf=3.20.3 -> is the latest version available that works according to another task.
grpcio=1.49.1 -> I can not go lower, I am getting an installation error, with lower versions of grpcio.

With my setup running on NixOS:

Python 3.11.8
Poetry 1.7.1
Ansible 8.7.0 (Ansible Core 2.15)

I am getting this error:

An exception occurred during task execution. To see the full traceback, use -vvv. The error was: AttributeError: 'Connection' object has no attribute 'nonetype'
fatal: [10.0.11.2]: FAILED! => {"msg": "Unexpected failure during module execution: 'Connection' object has no attribute 'nonetype'"}

I am trying this on a SONiC VS switch that supports GNMI.

---
ansible_user: admin
ansible_password: YourPaSsWoRd
ansible_become_pass: YourPaSsWoRd
ansible_port: 8080
ansible_connection: nokia.grpc.gnmi
ansible_gnmi_encoding: JSON

Modules fail to exucute successfully on ISAM devices

I was using the sros_command & sros_config modules to manage some ISAM OLT's but have been getting the error mentioned here ansible/ansible#72018
In that thread it was mentioned by jurajama that the sros_command & sros_config modules should no longer be used but this collection should instead.

I've tried for many days now and I'm unable to successfully connect to my OLT's using the cli_command module in this collection. I just get "command timeout triggered, timeout value is 60 secs.\nSee the timeout setting options in the Network Debug and Troubleshooting Guide."

Am I missing something?

Are the sros_command & sros_config modules still the recommended method to manage OLT's?

admin save config doesn't seem to work in classic mode

  • name: Save running config
    cli_command:
    command: admin save
    vars:
    ansible_command_timeout: 60

I am constantly getting timeout. What is going on here? Command line works fine but ansible cli_command not working?

The full traceback is:
File "/var/folders/m9/j7h7j2g96c33vvn0_y_qxt08j64y0y/T/ansible_cli_command_payload_wwossy9z/ansible_cli_command_payload.zip/ansible_collections/ansible/netcommon/plugins/modules/cli_command.py", line 169, in main
File "/var/folders/m9/j7h7j2g96c33vvn0_y_qxt08j64y0y/T/ansible_cli_command_payload_wwossy9z/ansible_cli_command_payload.zip/ansible/module_utils/connection.py", line 200, in rpc
raise ConnectionError(to_text(msg, errors='surrogate_then_replace'), code=code)
fatal: [10.214.148.11]: FAILED! => {
"changed": false,
"invocation": {
"module_args": {
"answer": null,
"check_all": false,
"command": "admin save",
"newline": true,
"prompt": null,
"sendonly": false
}
},
"msg": "command timeout triggered, timeout value is 60 secs.\nSee the timeout setting options in the Network Debug and Troubleshooting Guide."
}

cli_command does not return failed commands to ansible

When cli_command are executed, it does not seem to catch the CLI errors or notify ansible, every play seems a success. The failures are in the text, but "failed: false" is what ansible gets back. If any command fails, the user has to do their own error checking and walk through the output to find any command errors to know that the command did not succeed.

- hosts: nokiavalidator5
  gather_facts: no
  connection: network_cli
  vars:
       ansible_network_os: nokia.sros.classic
  collections:
  - nokia.sros
  tasks:

  - name: side load nokia config
    command: "sshpass -p \"{{ansible_password}}\" scp -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no \"../files/router1.nso5/.router1.nso5-safeconfig\" {{ansible_user}}@{{inventory_hostname}}:safeconfig"
    delegate_to: localhost


  - name: sros command load the config
    #sros_command:
       #commands: "{{ item }}"
    cli_command:
      command: "{{ item }}"
    with_items:
      - "exec safeconfig"
    register: outputregister

    
  - name: show register output
    debug:
          msg: "{{outputregister}}"


TASK [sros command load the config old school] *******************************************************************************
ok: [nokiavalidator5] => (item=exec safeconfig)


TASK [show register output] **************************************************************************************************
ok: [nokiavalidator5] => {
    "msg": {
        "changed": false,
        "deprecations": [
            {
                "msg": "Distribution Ubuntu 18.04 on host nokiavalidator5 should use /usr/bin/python3, but is using /usr/bin/python for backward compatibility with prior Ansible releases. A future Ansible release will default to using the discovered platform python for this host. See https://docs.ansible.com/ansible/2.9/reference_appendices/interpreter_discovery.html for more information",
                "version": "2.12"
            }
        ],
        "msg": "All items completed",
        "results": [
            {
                "ansible_facts": {
                    "discovered_interpreter_python": "/usr/bin/python"
                },
                "ansible_loop_var": "item",
                "changed": false,
                "failed": false,
                "invocation": {
                    "module_args": {
                        "answer": null,
                        "check_all": false,
                        "command": "exec safeconfig",
                        "newline": true,
                        "prompt": null,
                        "sendonly": false
                    }
                },
                "item": "exec safeconfig",
                "stdout": "Pre-processing configuration file (V0v0)...\n 2,048 lines\n 4,096 lines\n 6,144 lines\n 8,192 lines\n 10,240 lines\n 12,288 lines\n 14,336 lines\nCompleted processing 14,844 lines in 0.1 seconds\nWARNING: CLI Already in edit mode. Abort or commit current edit session.\u0007\n 512 lines\n 1,024 lines\n 1,536 lines\n 2,048 lines\n 2,560 lines\n 3,072 lines\n 3,584 lines\n 4,096 lines\n 4,608 lines\n 5,120 lines\n                      \n\nMAJOR: CLI #1009 An error occurred while processing a CLI command - \nFile cf3:\\safeconfig, Line 5382: Command \"community \"martian-community-peer\" members \"^(3356):((1.{3,4})|([256].*)|([1347-9])$|(77[7-9]$))|^(3549):((3[0-5][0-9] [0-9][0-9])|([1-5][0-9][0-9][0-1])$|(77[7-9]$))|^(65000):(649[56789]0)\"\" failed.\u0007",
                "stdout_lines": [
                    "Pre-processing configuration file (V0v0)...",
                    " 2,048 lines",
                    " 4,096 lines",
                    " 6,144 lines",
                    " 8,192 lines",
                    " 10,240 lines",
                    " 12,288 lines",
                    " 14,336 lines",
                    "Completed processing 14,844 lines in 0.1 seconds",
                    "WARNING: CLI Already in edit mode. Abort or commit current edit session.\u0007",
                    " 512 lines",
                    " 1,024 lines",
                    " 1,536 lines",
                    " 2,048 lines",
                    " 2,560 lines",
                    " 3,072 lines",
                    " 3,584 lines",
                    " 4,096 lines",
                    " 4,608 lines",
                    " 5,120 lines",
                    "                      ",
                    "",
                    "MAJOR: CLI #1009 An error occurred while processing a CLI command - ",

vagrant@ubuntu-bionic:~/git/ansible-verifier$ ansible --version
ansible 2.9.9

vagrant@ubuntu-bionic:~/git/ansible-verifier$ ansible-galaxy collection install --force nokia.sros
Process install dependency map
Starting collection install process
Installing 'nokia.sros:1.4.6' to '/home/vagrant/.ansible/collections/ansible_collections/nokia/sros'

*A:router1.nso5# show version
TiMOS-C-16.0.R9 cpm/x86_64 Nokia 7750 SR Copyright (c) 2000-2019 Nokia.
All rights reserved. All use subject to applicable license agreements.
Built on Wed Aug 21 12:25:15 PDT 2019 by builder in /builds/c/160B/R9/panos/main

Automatic revert time-out when subscribers are active

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.

communication fails on SROS version 21.2.R1

I am unable to get the connection going with the combination I have at hand of ansible and SROS versions. This was a playbook I have used in the past successfully. Apart from this I have tried to read status from the switch using other playbooks as well. But the error seems to be consistant with all of them. i.e. "[Errno -2] Name or service not known".
Wanted to check what service I am missing here..
The full error is as follows:-

[root@ansible ~]# ansible-playbook sros.play -vvv
ansible-playbook 2.10.9
  config file = /root/ansible.cfg
  configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/local/lib/python3.6/site-packages/ansible
  executable location = /usr/local/bin/ansible-playbook
  python version = 3.6.8 (default, Aug 24 2020, 17:57:11) [GCC 8.3.1 20191121 (Red Hat 8.3.1-5)]
Using /root/ansible.cfg as config file
host_list declined parsing /root/host as it did not pass its verify_file() method
script declined parsing /root/host as it did not pass its verify_file() method
auto declined parsing /root/host as it did not pass its verify_file() method
Parsed /root/host inventory source with ini plugin
redirecting (type: action) ansible.builtin.cli_config to ansible.netcommon.cli_config
redirecting (type: callback) ansible.builtin.yaml to community.general.yaml
redirecting (type: callback) ansible.builtin.yaml to community.general.yaml
Skipping callback 'default', as we already have a stdout callback.
Skipping callback 'minimal', as we already have a stdout callback.
Skipping callback 'oneline', as we already have a stdout callback.

PLAYBOOK: sros.play **************************************************************************************************************************************************************************************************************************************************************************
1 plays in sros.play

PLAY [Updating configs for L5 on R1 and R2] **************************************************************************************************************************************************************************************************************************************************
META: ran handlers
redirecting (type: action) ansible.builtin.cli_config to ansible.netcommon.cli_config

TASK [Show config] ***************************************************************************************************************************************************************************************************************************************************************************
task path: /root/sros.play:9
redirecting (type: connection) ansible.builtin.network_cli to ansible.netcommon.network_cli
redirecting (type: action) ansible.builtin.cli_config to ansible.netcommon.cli_config
redirecting (type: action) ansible.builtin.cli_config to ansible.netcommon.cli_config
<clab-DigitalEdgePOC-R1> ESTABLISH LOCAL CONNECTION FOR USER: root
<clab-DigitalEdgePOC-R1> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /root/.ansible/tmp/ansible-local-1426j79fmgkz `"&& mkdir "` echo /root/.ansible/tmp/ansible-local-1426j79fmgkz/ansible-tmp-1621237908.0852578-1432-248476235741582 `" && echo ansible-tmp-1621237908.0852578-1432-248476235741582="` echo /root/.ansible/tmp/ansible-local-1426j79fmgkz/ansible-tmp-1621237908.0852578-1432-248476235741582 `" ) && sleep 0'
redirecting (type: modules) ansible.builtin.cli_config to ansible.netcommon.cli_config
<clab-DigitalEdgePOC-R1> Attempting python interpreter discovery
<clab-DigitalEdgePOC-R1> EXEC /bin/sh -c 'echo PLATFORM; uname; echo FOUND; command -v '"'"'/usr/bin/python'"'"'; command -v '"'"'python3.7'"'"'; command -v '"'"'python3.6'"'"'; command -v '"'"'python3.5'"'"'; command -v '"'"'python2.7'"'"'; command -v '"'"'python2.6'"'"'; command -v '"'"'/usr/libexec/platform-python'"'"'; command -v '"'"'/usr/bin/python3'"'"'; command -v '"'"'python'"'"'; echo ENDFOUND && sleep 0'
<clab-DigitalEdgePOC-R1> EXEC /bin/sh -c '/usr/bin/python && sleep 0'
Using module file /root/.ansible/collections/ansible_collections/ansible/netcommon/plugins/modules/cli_config.py
<clab-DigitalEdgePOC-R1> PUT /root/.ansible/tmp/ansible-local-1426j79fmgkz/tmprim8b63t TO /root/.ansible/tmp/ansible-local-1426j79fmgkz/ansible-tmp-1621237908.0852578-1432-248476235741582/AnsiballZ_cli_config.py
<clab-DigitalEdgePOC-R1> EXEC /bin/sh -c 'chmod u+x /root/.ansible/tmp/ansible-local-1426j79fmgkz/ansible-tmp-1621237908.0852578-1432-248476235741582/ /root/.ansible/tmp/ansible-local-1426j79fmgkz/ansible-tmp-1621237908.0852578-1432-248476235741582/AnsiballZ_cli_config.py && sleep 0'
<clab-DigitalEdgePOC-R1> EXEC /bin/sh -c '/usr/bin/python /root/.ansible/tmp/ansible-local-1426j79fmgkz/ansible-tmp-1621237908.0852578-1432-248476235741582/AnsiballZ_cli_config.py && sleep 0'
<clab-DigitalEdgePOC-R1> EXEC /bin/sh -c 'rm -f -r /root/.ansible/tmp/ansible-local-1426j79fmgkz/ansible-tmp-1621237908.0852578-1432-248476235741582/ > /dev/null 2>&1 && sleep 0'
The full traceback is:
Traceback (most recent call last):
  File "/root/.ansible/tmp/ansible-local-1426j79fmgkz/ansible-tmp-1621237908.0852578-1432-248476235741582/AnsiballZ_cli_config.py", line 102, in <module>
    _ansiballz_main()
  File "/root/.ansible/tmp/ansible-local-1426j79fmgkz/ansible-tmp-1621237908.0852578-1432-248476235741582/AnsiballZ_cli_config.py", line 94, in _ansiballz_main
    invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)
  File "/root/.ansible/tmp/ansible-local-1426j79fmgkz/ansible-tmp-1621237908.0852578-1432-248476235741582/AnsiballZ_cli_config.py", line 40, in invoke_module
    runpy.run_module(mod_name='ansible_collections.ansible.netcommon.plugins.modules.cli_config', init_globals=None, run_name='__main__', alter_sys=True)
  File "/usr/lib64/python3.6/runpy.py", line 205, in run_module
    return _run_module_code(code, init_globals, run_name, mod_spec)
  File "/usr/lib64/python3.6/runpy.py", line 96, in _run_module_code
    mod_name, mod_spec, pkg_name, script_name)
  File "/usr/lib64/python3.6/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/tmp/ansible_cli_config_payload_yn5j4sju/ansible_cli_config_payload.zip/ansible_collections/ansible/netcommon/plugins/modules/cli_config.py", line 475, in <module>
  File "/tmp/ansible_cli_config_payload_yn5j4sju/ansible_cli_config_payload.zip/ansible_collections/ansible/netcommon/plugins/modules/cli_config.py", line 428, in main
  File "/tmp/ansible_cli_config_payload_yn5j4sju/ansible_cli_config_payload.zip/ansible/module_utils/connection.py", line 195, in __rpc__
ansible.module_utils.connection.ConnectionError: [Errno -2] Name or service not known
[DEPRECATION WARNING]: Distribution centos 8.3.2011 on host clab-DigitalEdgePOC-R1 should use /usr/libexec/platform-python, but is using /usr/bin/python for backward compatibility with prior Ansible releases. A future Ansible release will default to using the discovered platform
python for this host. See https://docs.ansible.com/ansible/2.10/reference_appendices/interpreter_discovery.html for more information. This feature will be removed in version 2.12. Deprecation warnings can be disabled by setting deprecation_warnings=False in ansible.cfg.
fatal: [clab-DigitalEdgePOC-R1]: FAILED! => changed=false
  ansible_facts:
    discovered_interpreter_python: /usr/bin/python
  module_stderr: |-
    Traceback (most recent call last):
      File "/root/.ansible/tmp/ansible-local-1426j79fmgkz/ansible-tmp-1621237908.0852578-1432-248476235741582/AnsiballZ_cli_config.py", line 102, in <module>
        _ansiballz_main()
      File "/root/.ansible/tmp/ansible-local-1426j79fmgkz/ansible-tmp-1621237908.0852578-1432-248476235741582/AnsiballZ_cli_config.py", line 94, in _ansiballz_main
        invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)
      File "/root/.ansible/tmp/ansible-local-1426j79fmgkz/ansible-tmp-1621237908.0852578-1432-248476235741582/AnsiballZ_cli_config.py", line 40, in invoke_module
        runpy.run_module(mod_name='ansible_collections.ansible.netcommon.plugins.modules.cli_config', init_globals=None, run_name='__main__', alter_sys=True)
      File "/usr/lib64/python3.6/runpy.py", line 205, in run_module
        return _run_module_code(code, init_globals, run_name, mod_spec)
      File "/usr/lib64/python3.6/runpy.py", line 96, in _run_module_code
        mod_name, mod_spec, pkg_name, script_name)
      File "/usr/lib64/python3.6/runpy.py", line 85, in _run_code
        exec(code, run_globals)
      File "/tmp/ansible_cli_config_payload_yn5j4sju/ansible_cli_config_payload.zip/ansible_collections/ansible/netcommon/plugins/modules/cli_config.py", line 475, in <module>
      File "/tmp/ansible_cli_config_payload_yn5j4sju/ansible_cli_config_payload.zip/ansible_collections/ansible/netcommon/plugins/modules/cli_config.py", line 428, in main
      File "/tmp/ansible_cli_config_payload_yn5j4sju/ansible_cli_config_payload.zip/ansible/module_utils/connection.py", line 195, in __rpc__
    ansible.module_utils.connection.ConnectionError: [Errno -2] Name or service not known
  module_stdout: ''
  msg: |-
    MODULE FAILURE
    See stdout/stderr for the exact error
  rc: 1

PLAY RECAP ***********************************************************************************************************************************************************************************************************************************************************************************
clab-DigitalEdgePOC-R1     : ok=0    changed=0    unreachable=0    failed=1    skipped=0    rescued=0    ignored=0

Here is the setup:-

SROS version:-

A:R1# show version
TiMOS-B-21.2.R1 both/x86_64 Nokia 7750 SR Copyright (c) 2000-2021 Nokia.



Playbook:-

[root@ansible ~]# cat sros.play
---
- name: Updating configs for L5 on R1 and R2
  hosts: R1
  gather_facts: no
  connection: network_cli
  collections:
  - nokia.sros
  tasks:
   - name: Show config
     cli_config:
        config: |
           configure router "Base" bgp
            neighbor "3.3.3.5"
            admin-state enable
            group "IBGP-EVPN-RR"
            exit all



Host file  :-

[sros]
R1
[sros:vars]
ansible_network_os=nokia.sros.md
ansible_user=admin
ansible_password=admin
ANSIBLE_ACTION_WARNINGS=False

Need custom "origin" support for Cisco devices

  • origin - a field which MAY be used to disambiguate the path if necessary. For example, the origin may be used to indicate which organization defined the schema to which the path belongs.

Cisco devices support OpenConfig models, IETF models, and native Cisco models. The devices require the client to populate the "origin" field in order to disambiguate the path when trying to configure resources. The "origin" field needs to be available for setting in the playbook so that it can be assigned to the Path message.

Collection does not appear to support FQCN

There are generally two ways to use collections in Ansible.

You can include them at the play level, which appears to be required by Nokia. The following snippet is from the Nokia docs:

  collections:
  - nokia.sros

  tasks:
  - name: get system information
    cli_command:
      command: show system information
    register: output1

Or, you can use the FQCN approach:

  tasks:
  - name: get system information
    nokia.sros.cli_command:
      command: show system information
    register: output1

The latter approach does not appear to be supported. It is not clear whether this is an Ansible issue or a Nokia issue. I personally believe it to be a Nokia issue because the modules/ directory does not contain cli_command, which appears to be dynamically (?) made available only after the collection is imported at the play level. In this way, it cannot work with the FQCN method, which also explains why it does not appear in the "content" tab of the galaxy documentation.

Note that Ansible recommends FQCNs: "We recommend you start using the fully-qualified collection name (FQCN) in your playbooks as the explicit and authoritative indicator of which collection to use ..."

Cannot use cli_command when VSR does not have license installed

I'm using nokia.sros collection for managing VSR release 19.10.R3. The ansible_network_os mode is nokia.sros.light.

  • Ansible version is 2.9.19 running with python 3.8.8 on CentOS-8.3 based Docker container.
  • ansible.netcommon version 2.0.1
  • nokia.sros version 1.6.0

Initially when the VSR VM is started, it will not have a license. Then I transfer the license file to VSR (using Nokia Centralized License Manager application) and try to reboot VSR to apply the license using task:

- name: Reboot VSR VM
  cli_command:
    command: "admin reboot now"

That fails with:

fatal: [xxxxxxxx]: FAILED! => {"ansible_facts": {"discovered_interpreter_python": "/usr/bin/python"}, "changed": false, "msg": "show system information\r\n                   ^\r\nError: Invalid parameter. \r\nA:VSR# "}

The reason for failure is that when the license is not activated, VSR does not support "show system information" command but nokia.sros plugin always wants to run that first.

A:VSR# show system information
                   ^
Error: Invalid parameter.

Would there be some way to enhance the implementation to support also this use case where I just want to run a simple command and nokia.sros could ignore trying to read the system information?

network os nokia.sros.md is not supported

Hi!
Currently I have this task:
- name: Collect show debug
cli_command:
command: show debug
register: show_debug
vars:
ansible_user: "ansible_networking"
ansible_network_os: "nokia.sros.md"
and I am using nokia.sros collection:
collections:
- nokia.sros

However, it fails with the error:
fatal: [device-name]: FAILED! => {
"msg": "network os nokia.sros.md is not supported"
}
When I used debug verbose, I could see it use cli_command from ansible.netcommon:
redirecting (type: action) ansible.builtin.cli_command to ansible.netcommon.cli_command
redirecting (type: connection) ansible.builtin.network_cli to ansible.netcommon.network_cli
Is that correct?

ansible 2.10 No module named 'ansible.module_utils.network'

I am upgrading to ansible 2.10 and the noakia.sros module is failing when trying to execute a command on a device (it works fine with 2.9 and versions 1.5.0 of the collection). I don't see any module dependencies listed that I need to install... seems to be something different with 2.10 perhaps.

vagrant@ubuntu-bionic:/usr/local$ ansible --version
ansible 2.10.2
  config file = None
  configured module search path = ['/home/vagrant/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/local/lib/python3.6/dist-packages/ansible
  executable location = /usr/local/bin/ansible
  python version = 3.6.9 (default, Oct  8 2020, 12:12:24) [GCC 8.4.0]

vagrant@ubuntu-bionic:/usr/local$ more ~/.ansible/collections/ansible_collections/nokia/sros/MANIFEST.json 
{
 "collection_info": {
  "namespace": "nokia",
  "name": "sros",
  "version": "1.5.0",
- hosts: nokiavalidator5
  gather_facts: no
  connection: network_cli
  vars:
       ansible_network_os: nokia.sros.classic
  collections:
  - nokia.sros
  tasks:


  - name: sros command load the config old school
    cli_command:
      command: "{{ item }}"
    with_items:
      - "exec safeconfig"
    register: outputregister
TASK [sros command load the config old school] ****************************************************************************
task path: /home/vagrant/git/ansible-verifier/testconfigs.yml:1062
redirecting (type: connection) ansible.builtin.network_cli to ansible.netcommon.network_cli
The full traceback is:
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/dist-packages/ansible/executor/task_executor.py", line 124, in run
    item_results = self._run_loop(items)
  File "/usr/local/lib/python3.6/dist-packages/ansible/executor/task_executor.py", line 357, in _run_loop
    res = self._execute(variables=task_vars)
  File "/usr/local/lib/python3.6/dist-packages/ansible/executor/task_executor.py", line 613, in _execute
    self._connection = self._get_connection(cvars, templar)
  File "/usr/local/lib/python3.6/dist-packages/ansible/executor/task_executor.py", line 913, in _get_connection
    ansible_playbook_pid=to_text(os.getppid())
  File "/usr/local/lib/python3.6/dist-packages/ansible/plugins/loader.py", line 826, in get_with_context
    obj.__init__(instance, *args, **kwargs)
  File "/usr/local/lib/python3.6/dist-packages/ansible_collections/ansible/netcommon/plugins/connection/network_cli.py", line 354, in __init__
    self.cliconf = cliconf_loader.get(self._network_os, self)
  File "/usr/local/lib/python3.6/dist-packages/ansible/plugins/loader.py", line 780, in get
    return self.get_with_context(name, *args, **kwargs).object
  File "/usr/local/lib/python3.6/dist-packages/ansible/plugins/loader.py", line 800, in get_with_context
    self._module_cache[path] = self._load_module_source(name, path)
  File "/usr/local/lib/python3.6/dist-packages/ansible/plugins/loader.py", line 764, in _load_module_source
    spec.loader.exec_module(module)
  File "<frozen importlib._bootstrap_external>", line 678, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/home/vagrant/.ansible/collections/ansible_collections/nokia/sros/plugins/cliconf/classic.py", line 25, in <module>
    from ansible.module_utils.network.common.utils import to_list
ModuleNotFoundError: No module named 'ansible.module_utils.network'
fatal: [nokiavalidator5]: FAILED! => {
    "msg": "Unexpected failure during module execution.",
    "stdout": ""
}

cli_command etc. cannot be fully qualified

The collection does not allow the commands to be fully qualified like regular collections. We need be able to fully qualify the namespace for "cli_command" so that we do not collide with other modules or collections from other vendors. The following will work, however, fully qualifying the roles/modules etc. should be a standard.

  - name: sros command load the config
    nokia.sros.cli_command:
vagrant@ubuntu-bionic:~/git/ansible-verifier$ ansible-playbook -i hosts nokia-testconfigs.yml --tags=ear1.nso5
ERROR! couldn't resolve module/action 'nokia.sros.cli_command'. This often indicates a misspelling, missing collection, or incorrect module path.

yes the following will work, but so should "nokia.sros.cli_command".

  collections:
  - nokia.sros


Ansible Galaxy package has not been updated for 2 years

It lacks a trivial but fundamental fix, rendering it useless.

Suggestion: Recommend users to install from the git repo directly:

ansible-galaxy collection install git+https://github.com/nokia/ansible-networking-collections.git#/grpc/

cli_config reply message doesn't contain INFO messages

Hi,
Cli_config is better than the previous sros_config module as now, we can have a feedback message for the router.
It’s very useful to manage error messages:
For instance, trying to configure a service customer’s MSS with an wrong lag number:
The register variable of the cli_config task contains the 2 following important variable:

  • "msg": "configure service customer 336666661 multi-service-site "MSS-test" assignment port lag-3 \r\nMINOR: CLI 'create' is mandatory while creating multi-service-site.\u0007\r\n*A:LABROUTER#
  • “failed”: true

After some tests, we observed that MINOR, MAJOR and CRITICAL error messages were correctly send back from the router.
But unfortunately, that is not the case for INFO messages ! :(
For instance, trying to add a bgp neighbor in a bgp group when this bgp neighbor is already configured in another bgp group:
1/ We have an INFO message in direct CLI:
*A:LABROUTER# configure router bgp group "GRP-IBGPV6-RR" neighbor 10.10.127.1
INFO: BGP #1001 Configuration failed because of inconsistent values - Peer 10.10.127.1 already belongs to group "GRP-IBGP-RR" (VR 1): cannot be changed!

Even this is an INFO message, from our point of view, it a real config error.

2/ Doing the same thing with Ansible and cli_config:

  • name: do some config
    cli_config:
    config: |
    configure router bgp group "GRP-IBGPV6-RR" neighbor 10.10.127.1
    exit all
    vars:
    • ansible_network_os: nokia.sros.classic
    • ansible_connection: network_cli
    • ansible_command_timeout: 600
      register: output2
  • debug:
    var: output2

The output2 register variable does not contains any “msg” content, and the “failed” is set to false :(
It’s not good for error management.
Rgds,

Please update collection!

Please update SROS collection to work with Ansible Automation Platform Controller 4.2.1. It's been 3 years since the last updates have posted.
Thanks!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.