Giter Club home page Giter Club logo

cisco.iosxr's People

Contributors

andersson007 avatar ansible-zuul[bot] avatar ashwini-mhatre avatar capttrews avatar dericcrago avatar dsavineau avatar ganeshrn avatar gomathiselvis avatar jamestiotio avatar justjais avatar kb-perbyte avatar kstpktr avatar nilashishc avatar olemyhre avatar pabelanger avatar pre-commit-ci[bot] avatar qalthos avatar rohitthakur2590 avatar roverflow avatar ruchip16 avatar samccann avatar sean-m-sullivan avatar sivel avatar tweippert avatar xorrkaz 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  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

cisco.iosxr's Issues

local variable 'start_index' referenced before assignment with cisco.iosxr.iosxr_config

Ansible version: 2.9.13

Hello,

I'm trying to create this part of config:
extcommunity-set rt VRF1234
6667:1234
end-set

to do this I perform:

  • name: Configure the extcommunity-set
    cisco.iosxr.iosxr_config:
    lines:
    - 6667:1234
    - end-set
    parents: extcommunity-set rt VRF1234

but it fails with this error: local variable 'start_index' referenced before assignment

The full traceback is:
WARNING: The below traceback may not be related to the actual failure.
File "/var/folders/wz/88zy3s2x13l_8lh478p6d3300000gn/T/ansible_cisco.iosxr.iosxr_config_payload_M6tYdA/ansible_cisco.iosxr.iosxr_config_payload.zip/ansible_collections/cisco/iosxr/plugins/modules/iosxr_config.py", line 355, in run
File "/var/folders/wz/88zy3s2x13l_8lh478p6d3300000gn/T/ansible_cisco.iosxr.iosxr_config_payload_M6tYdA/ansible_cisco.iosxr.iosxr_config_payload.zip/ansible/module_utils/connection.py", line 185, in rpc
raise ConnectionError(to_text(msg, errors='surrogate_then_replace'), code=code)
fatal: [asr9000v]: FAILED! => {
"changed": false,
"invocation": {
"module_args": {
"admin": false,
"after": null,
"backup": false,
"backup_options": null,
"before": null,
"comment": "configured by iosxr_config",
"config": null,
"exclusive": false,
"force": false,
"label": null,
"lines": [
"6667:1234",
"end-set"
],
"match": "line",
"parents": [
"extcommunity-set rt VRF1234"
],
"provider": null,
"replace": "line",
"src": null
}
},
"msg": "local variable 'start_index' referenced before assignment"

Because I use the same module to create some prefix-set (iosxr syntax is quite the same), I don't see what I'm missing for the extcommunity-set.

Kind regards;

ansible ignore some lines on pushing prefix-set configuration

From @RehabRezek on Jun 10, 2020 09:19

Hello,
i'm trying to push this prefix-set configuration on cisco ioxr with ansible

prefix-set SWH22
  10.7.182.0/24,
  # EnodeB-S1-SADAT
  10.77.183.0/24,
  # EnodeB-S1-
  10.7.186.0/24,
  # EnodeB-S1-Bosh
  10.77.187.0/24,
  # test
  10.77.188.0/24
end-set

which are ip and comment for each prefix-set
but in every time ansible ignore the comment line and only ips are pushing to device
any help if someone tried to push prefix-set before!?

Copied from original issue: ansible/ansible#69980

iosxr.config not working for NCS5501 running 7.0.2

SUMMARY

I'm trying to use the ansible configuration module to configure an NCS5501. I've used the same playbooks etc to push configuration to an NCS540 running the same version of firmware. The configuration I'm pushing is really minimal, so I don't believe it's an issue there.

When trying to use the module, I get a mountain of errors.

I've seen bug report #52 which looks similar on the face of it, however I've tried applying the patch in #60, as well as upgrading to the 1.6 beta which appears to include this patch, but neither work.

ISSUE TYPE
  • Bug Report
COMPONENT NAME
ANSIBLE VERSION
ansible 2.9.13
  config file = /Users/dave.bell/git/iosxr-role-agr/ansible.cfg
  configured module search path = ['/Users/dave.bell/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /Users/dave.bell/Library/Python/3.8/lib/python/site-packages/ansible
  executable location = /Users/dave.bell/Library/Python/3.8/bin/ansible
  python version = 3.8.5 (v3.8.5:580fbb018f, Jul 20 2020, 12:11:27) [Clang 6.0 (clang-600.0.57)]
CONFIGURATION
DEFAULT_GATHERING(/Users/dave.bell/git/iosxr-role-agr/ansible.cfg) = explicit
HOST_KEY_CHECKING(/Users/dave.bell/git/iosxr-role-agr/ansible.cfg) = False
INTERPRETER_PYTHON(/Users/dave.bell/git/iosxr-role-agr/ansible.cfg) = /usr/bin/python3
INVENTORY_ENABLED(/Users/dave.bell/git/iosxr-role-agr/ansible.cfg) = ['yaml']
RETRY_FILES_ENABLED(/Users/dave.bell/git/iosxr-role-agr/ansible.cfg) = False
OS / ENVIRONMENT

NCS5501 running IOS XR 7.0.2

STEPS TO REPRODUCE

Try to run the playbook below.

---
- name: Replace configuration on device
  hosts: R1
  vars:
    ansible_user: "user"
    ansible_password: "pass"
  tasks:
  - name: load a config from disk and replace the current config
    cisco.iosxr.iosxr_config:
      src: "{{inventory_hostname}}_config.cfg"
      replace: config
      backup: yes
EXPECTED RESULTS

The configuration gets applied to the router

ACTUAL RESULTS

The playbook bombs out with an error

dave-bell-mac:iosxr-role-agr dave.bell$ ansible-playbook -i lab.yml test.yml   -vvvv
ansible-playbook 2.9.13
  config file = /Users/dave.bell/git/iosxr-role-agr/ansible.cfg
  configured module search path = ['/Users/dave.bell/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /Users/dave.bell/Library/Python/3.8/lib/python/site-packages/ansible
  executable location = /Users/dave.bell/Library/Python/3.8/bin/ansible-playbook
  python version = 3.8.5 (v3.8.5:580fbb018f, Jul 20 2020, 12:11:27) [Clang 6.0 (clang-600.0.57)]
Using /Users/dave.bell/git/iosxr-role-agr/ansible.cfg as config file
setting up inventory plugins
Parsed /Users/dave.bell/git/iosxr-role-agr/lab.yml inventory source with yaml plugin
Loading callback plugin default of type stdout, v2.0 from /Users/dave.bell/Library/Python/3.8/lib/python/site-packages/ansible/plugins/callback/default.py

PLAYBOOK: test.yml ****************************************************************************************************************************************************************
Positional arguments: test.yml
verbosity: 4
connection: smart
timeout: 10
become_method: sudo
tags: ('all',)
inventory: ('/Users/dave.bell/git/iosxr-role-agr/lab.yml',)
forks: 5
1 plays in test.yml

PLAY [Replace configuration on device] ********************************************************************************************************************************************
META: ran handlers

TASK [load a config from disk and replace the current config] *********************************************************************************************************************
task path: /Users/dave.bell/git/iosxr-role-agr/test.yml:8
<88.98.51.4> attempting to start connection
<88.98.51.4> using connection plugin network_cli
<88.98.51.4> local domain socket does not exist, starting it
<88.98.51.4> control socket path is /Users/dave.bell/.ansible/pc/4f58e38d57
<88.98.51.4> local domain socket listeners started successfully
<88.98.51.4> loaded cliconf plugin iosxr from path /Users/dave.bell/Library/Python/3.8/lib/python/site-packages/ansible/plugins/cliconf/iosxr.py for network_os iosxr
<88.98.51.4>
<88.98.51.4> local domain socket path is /Users/dave.bell/.ansible/pc/4f58e38d57
<88.98.51.4> ESTABLISH LOCAL CONNECTION FOR USER: dave.bell
<88.98.51.4> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /Users/dave.bell/.ansible/tmp/ansible-local-78320bsz1ytk9 `"&& mkdir "` echo /Users/dave.bell/.ansible/tmp/ansible-local-78320bsz1ytk9/ansible-tmp-1600873946.938285-78325-267256065884534 `" && echo ansible-tmp-1600873946.938285-78325-267256065884534="` echo /Users/dave.bell/.ansible/tmp/ansible-local-78320bsz1ytk9/ansible-tmp-1600873946.938285-78325-267256065884534 `" ) && sleep 0'
Using module file /Users/dave.bell/.ansible/collections/ansible_collections/cisco/iosxr/plugins/modules/iosxr_config.py
<88.98.51.4> PUT /Users/dave.bell/.ansible/tmp/ansible-local-78320bsz1ytk9/tmp0dz7bc79 TO /Users/dave.bell/.ansible/tmp/ansible-local-78320bsz1ytk9/ansible-tmp-1600873946.938285-78325-267256065884534/AnsiballZ_iosxr_config.py
<88.98.51.4> EXEC /bin/sh -c 'chmod u+x /Users/dave.bell/.ansible/tmp/ansible-local-78320bsz1ytk9/ansible-tmp-1600873946.938285-78325-267256065884534/ /Users/dave.bell/.ansible/tmp/ansible-local-78320bsz1ytk9/ansible-tmp-1600873946.938285-78325-267256065884534/AnsiballZ_iosxr_config.py && sleep 0'
<88.98.51.4> EXEC /bin/sh -c '/usr/bin/python3 /Users/dave.bell/.ansible/tmp/ansible-local-78320bsz1ytk9/ansible-tmp-1600873946.938285-78325-267256065884534/AnsiballZ_iosxr_config.py && sleep 0'
<88.98.51.4> EXEC /bin/sh -c 'rm -f -r /Users/dave.bell/.ansible/tmp/ansible-local-78320bsz1ytk9/ansible-tmp-1600873946.938285-78325-267256065884534/ > /dev/null 2>&1 && sleep 0'
The full traceback is:
Traceback (most recent call last):
  File "/Users/dave.bell/.ansible/tmp/ansible-local-78320bsz1ytk9/ansible-tmp-1600873946.938285-78325-267256065884534/AnsiballZ_iosxr_config.py", line 102, in <module>
    _ansiballz_main()
  File "/Users/dave.bell/.ansible/tmp/ansible-local-78320bsz1ytk9/ansible-tmp-1600873946.938285-78325-267256065884534/AnsiballZ_iosxr_config.py", line 94, in _ansiballz_main
    invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)
  File "/Users/dave.bell/.ansible/tmp/ansible-local-78320bsz1ytk9/ansible-tmp-1600873946.938285-78325-267256065884534/AnsiballZ_iosxr_config.py", line 40, in invoke_module
    runpy.run_module(mod_name='ansible_collections.cisco.iosxr.plugins.modules.iosxr_config', init_globals=None, run_name='__main__', alter_sys=True)
  File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.7/lib/python3.7/runpy.py", line 205, in run_module
    return _run_module_code(code, init_globals, run_name, mod_spec)
  File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.7/lib/python3.7/runpy.py", line 96, in _run_module_code
    mod_name, mod_spec, pkg_name, script_name)
  File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.7/lib/python3.7/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/var/folders/cy/ft02hrcn0vv2wl7w3_6ymx0h0000gp/T/ansible_cisco.iosxr.iosxr_config_payload_njmm_edk/ansible_cisco.iosxr.iosxr_config_payload.zip/ansible_collections/cisco/iosxr/plugins/modules/iosxr_config.py", line 465, in <module>
  File "/var/folders/cy/ft02hrcn0vv2wl7w3_6ymx0h0000gp/T/ansible_cisco.iosxr.iosxr_config_payload_njmm_edk/ansible_cisco.iosxr.iosxr_config_payload.zip/ansible_collections/cisco/iosxr/plugins/modules/iosxr_config.py", line 459, in main
  File "/var/folders/cy/ft02hrcn0vv2wl7w3_6ymx0h0000gp/T/ansible_cisco.iosxr.iosxr_config_payload_njmm_edk/ansible_cisco.iosxr.iosxr_config_payload.zip/ansible_collections/cisco/iosxr/plugins/modules/iosxr_config.py", line 363, in run
  File "/var/folders/cy/ft02hrcn0vv2wl7w3_6ymx0h0000gp/T/ansible_cisco.iosxr.iosxr_config_payload_njmm_edk/ansible_cisco.iosxr.iosxr_config_payload.zip/ansible/module_utils/connection.py", line 185, in __rpc__
ansible.module_utils.connection.ConnectionError: local variable 'start_index' referenced before assignment
fatal: [R1]: FAILED! => {
    "changed": false,
    "module_stderr": "Traceback (most recent call last):\n  File \"/Users/dave.bell/.ansible/tmp/ansible-local-78320bsz1ytk9/ansible-tmp-1600873946.938285-78325-267256065884534/AnsiballZ_iosxr_config.py\", line 102, in <module>\n    _ansiballz_main()\n  File \"/Users/dave.bell/.ansible/tmp/ansible-local-78320bsz1ytk9/ansible-tmp-1600873946.938285-78325-267256065884534/AnsiballZ_iosxr_config.py\", line 94, in _ansiballz_main\n    invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)\n  File \"/Users/dave.bell/.ansible/tmp/ansible-local-78320bsz1ytk9/ansible-tmp-1600873946.938285-78325-267256065884534/AnsiballZ_iosxr_config.py\", line 40, in invoke_module\n    runpy.run_module(mod_name='ansible_collections.cisco.iosxr.plugins.modules.iosxr_config', init_globals=None, run_name='__main__', alter_sys=True)\n  File \"/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.7/lib/python3.7/runpy.py\", line 205, in run_module\n    return _run_module_code(code, init_globals, run_name, mod_spec)\n  File \"/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.7/lib/python3.7/runpy.py\", line 96, in _run_module_code\n    mod_name, mod_spec, pkg_name, script_name)\n  File \"/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.7/lib/python3.7/runpy.py\", line 85, in _run_code\n    exec(code, run_globals)\n  File \"/var/folders/cy/ft02hrcn0vv2wl7w3_6ymx0h0000gp/T/ansible_cisco.iosxr.iosxr_config_payload_njmm_edk/ansible_cisco.iosxr.iosxr_config_payload.zip/ansible_collections/cisco/iosxr/plugins/modules/iosxr_config.py\", line 465, in <module>\n  File \"/var/folders/cy/ft02hrcn0vv2wl7w3_6ymx0h0000gp/T/ansible_cisco.iosxr.iosxr_config_payload_njmm_edk/ansible_cisco.iosxr.iosxr_config_payload.zip/ansible_collections/cisco/iosxr/plugins/modules/iosxr_config.py\", line 459, in main\n  File \"/var/folders/cy/ft02hrcn0vv2wl7w3_6ymx0h0000gp/T/ansible_cisco.iosxr.iosxr_config_payload_njmm_edk/ansible_cisco.iosxr.iosxr_config_payload.zip/ansible_collections/cisco/iosxr/plugins/modules/iosxr_config.py\", line 363, in run\n  File \"/var/folders/cy/ft02hrcn0vv2wl7w3_6ymx0h0000gp/T/ansible_cisco.iosxr.iosxr_config_payload_njmm_edk/ansible_cisco.iosxr.iosxr_config_payload.zip/ansible/module_utils/connection.py\", line 185, in __rpc__\nansible.module_utils.connection.ConnectionError: local variable 'start_index' referenced before assignment\n",
    "module_stdout": "",
    "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error",
    "rc": 1
}

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

iosxr_config broken (unexpected keyword arguments)

SUMMARY
ISSUE TYPE
  • Bug Report
COMPONENT NAME

response = conn.edit_config(

ANSIBLE VERSION
ansible 2.10.11
  config file = /etc/ansible/ansible.cfg
  configured module search path = ['/home/tpentzien/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python3/dist-packages/ansible
  executable location = /usr/bin/ansible
  python version = 3.6.9 (default, Jan 26 2021, 15:33:00) [GCC 8.4.0]

I originally got the error with ansible 2.9, i just tried ansible 2.10 with collections hoping the error is gone.

COLLECTION VERSION
cisco.iosxr 2.3.0

I originally got the error with ansible 2.9, i just tried ansible 2.10 with collections hoping the error is gone.

CONFIGURATION
OS / ENVIRONMENT

Ubuntu 18.04.5 LTS is the ansible host
Cisco IOS XE Software, Version 16.12.04 on WS-C3850-24T-E is the test switch

STEPS TO REPRODUCE

i've got some roles wich just roll out some jinja2 templates

---
- name: logging
  iosxr_config:
    #save_when: always
    src: "{{ role_path }}/template.j2"
    #force: yes
  become: yes
EXPECTED RESULTS

the templates should get rolled out

ACTUAL RESULTS

the templates never get rolled out because the module runs into errors

The full traceback is:
WARNING: The below traceback may *not* be related to the actual failure.
  File "/tmp/ansible_iosxr_config_payload_6AzgtQ/ansible_iosxr_config_payload.zip/ansible_collections/cisco/iosxr/plugins/module_utils/network/iosxr/iosxr.py", line 573, in load_config
    label=label,
  File "/tmp/ansible_iosxr_config_payload_6AzgtQ/ansible_iosxr_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.115.65]: FAILED! => {
    "ansible_facts": {
        "discovered_interpreter_python": "/usr/bin/python"
    },
    "changed": false,
    "invocation": {
        "module_args": {
            "admin": false,
            "after": null,
            "backup": false,
            "backup_options": null,
            "before": null,
            "comment": "configured by iosxr_config",
            "config": null,
            "exclusive": false,
            "force": false,
            "label": null,
            "lines": null,
            "match": "line",
            "parents": null,
            "provider": null,
            "replace": "line",
            "src": "`..."
        }
    },
    "msg": "edit_config() got an unexpected keyword argument 'exclusive'"
}

(in the following only msg changes)

this is the first error i got, i searched in the sourcecode and found the problem:

response = conn.edit_config(

first I commented exclusive=exclusive,, got error:

"msg": "edit_config() got an unexpected keyword argument 'admin'"

commended out admin=admin, too, got error:

"msg": "edit_config() got an unexpected keyword argument 'label'"

commented out label=label, too, final error:

    "msg": "commit comment is not supported"

after then commenting out comment=comment it finaly worked like expected

that part of the code now looks like this:

response = conn.edit_config(
                candidate=command_filter,
                commit=commit,
                #admin=admin,
                #exclusive=exclusive,
                replace=replace,
                #comment=comment,
                #label=label,
            )

that works... i don't know if my dirty fix broke some other functionality of the collection but i also had the problem with ansible 2.9 where the module is still part of the main ansible distribution, but somehow other users don't seem to have that problem?

iosxr_facts does not display the correct hostname for IOS-XR 64-bit

SUMMARY

iosxr_facts module doesn't capture the correct router hostname but instead shows as System. This only happens to IOS-XR running with 64-bit architecture

ISSUE TYPE
  • Bug Report
COMPONENT NAME

iosxr_facts

ANSIBLE VERSION
ansible 2.10.5
  config file = None
  configured module search path = ['/home/simon/.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]
CONFIGURATION

OS / ENVIRONMENT

Tested with Cisco NCS-5500 (7.2.1) and Cisco ASR9000 (7.1.2)

STEPS TO REPRODUCE

Sample router configuration.

RP/0/RSP0/CPU0:TEST-ROUTER#show run hostname
Tue Feb 9 15:33:25.729 AEST
hostname TEST-ROUTER

- name: IOS XR Pre Checks Playbook
  hosts: "{{ hosts_to_run }}"
  gather_facts: no
  serial: 1
  connection: network_cli

  tasks:
  - name: Get timestamp from the system
    shell: "date +%y%m%d_%H%M%S"
    register: tstamp

  - name: Gather router information
    iosxr_facts:
      gather_subset: 
        - "!interfaces"
EXPECTED RESULTS

Should expect "ansible_net_hostname": "TEST-ROUTER"

ACTUAL RESULTS

"ansible_net_hostname": "System"


iosxr_config replace: config uploads wrong config to device when targeting multiple systems

SUMMARY

When using the iosxr_config replace:config option the module appears to always upload the same config to all devices. When runnin the same playbook through with a single host selected the module successfully uploads and applies the configuration however results become unstable when targeting a group with multiple hosts

ISSUE TYPE
  • Bug Report
COMPONENT NAME

iosxr

ANSIBLE VERSION
ansible 2.9.9 
  config file = /etc/ansible/ansible.cfg
  configured module search path = [u'/home/srenshaw/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules'] 
  ansible python module location = /home/srenshaw/.local/lib/python2.7/site-packages/ansible
  executable location = /home/srenshaw/.local/bin/ansible
  python version = 2.7.17 (default, Apr 15 2020, 17:20:14) [GCC 7.5.0]
CONFIGURATION
DEFAULT_GATHERING = explicit
DEFAULT_JINJA2_EXTENSIONS= jinja2.ext.with_
HOST_KEY_CHECKING = False
INTERPRETER_PYTHON = auto
OS / ENVIRONMENT
STEPS TO REPRODUCE
[iosxr]
icf01
icf02
icf03
icf04

[dc2]
icf0[3:4]

[dc1]
icf0[1:2]

[dcx:children]
dc1
dc2


---
  - name: Generate and Commit Gold Config
    block:
        - name: Generate Golden Master
          template:
            src: "{{ os }}.j2"
            dest: "{{ config_dir }}/{{ inventory_hostname }}_golden_master.cfg"
          check_mode: no

        - name: Commit Golden Master
          iosxr_config:
            src: "{{ config_dir }}/{{ inventory_hostname }}_golden_master.cfg"
            replace: config
            provider: "{{ provider }}"
          when: gold_commit
EXPECTED RESULTS

When applying the above playbook devices should recieve their matching configurations files. eg:
icf03 - output/icf03_golden_master.cfg
icf04 - output/icf04_golden_master.cfg

ACTUAL RESULTS

When applied at the group level the configs are not applied properly and cause the devices to recieve the wrong config eg:
icf03 - output/icf03_golden_master.cfg
icf04 - output/icf03_golden_master.cfg

As a results some devices become unavailable as the wrong configs are pushed. in the above example icf04 becomes unavailable as it is now running icf03's config. in the below trimmed outputs you can see that icf03's diff indicates the first change will be to tacacs however the config going to icf04 wants to change the hostname first as it is recieving the wrong configuration

<10.69.2.19> EXEC /bin/sh -c 'rm -f -r /root/.ansible/tmp/ansible-tmp-1595456877.41-17076-17009141884094/ > /dev/null 2>&1 && sleep 0'
changed: [icf03] => {
    "changed": true, 
    "commands": [
        "load harddisk:/ansible_config.txt"
    ], 
    "diff": {
        "prepared": "Building configuration...\n!! IOS XR Configuration 7.0.2\n   tacacs-server 
<10.69.2.99> EXEC /bin/sh -c 'rm -f -r /root/.ansible/tmp/ansible-tmp-1595456877.37-17077-54185194722578/ > /dev/null 2>&1 && sleep 0'
changed: [icf04] => {
    "changed": true, 
    "commands": [
        "load harddisk:/ansible_config.txt"
    ], 
    "diff": {
        "prepared": "Building configuration...\n!! IOS XR Configuration 7.0.2\n<- hostname DC2-EP20-ICF04\n+> hostname DC2-EP19-ICF03\n   t

Trimmed copy of icf03_golden_master.cfg

hostname DC2-EP19-ICF03
---- Removed ----
tacacs source-interface MgmtEth0/RP0/CPU0/0 vrf Management
tacacs-server host 10.64.32.13 port 49
---- Removed ----

Trimmed copy of icf04_golden_master.cfg

hostname DC2-EP20-ICF04
---- Removed ----
tacacs source-interface MgmtEth0/RP0/CPU0/0 vrf Management
tacacs-server host 10.64.32.13 port 49
---- Removed ----

Issue can be mittigated by setting the throttle:1 option to the task. this results in routers recieving the correct config

  - name: Generate and Commit Gold Config
    block:
        - name: Generate Golden Master
          template:
            src: "{{ os }}.j2"
            dest: "{{ config_dir }}/{{ inventory_hostname }}_golden_master.cfg"
          check_mode: no

        - name: Commit Golden Master
          iosxr_config:
            src: "{{ config_dir }}/{{ inventory_hostname }}_golden_master.cfg"
            replace: config
            provider: "{{ provider }}"
          when: gold_commit
          throttle: 1

Unable to gather ACL Data from facts or iosxr_acls

SUMMARY

Unable to Gather ACL's utilizing them modules
cisco.iosxr.iosxr_acls
or
cisco.iosxr.iosxr_facts

ISSUE TYPE
  • Bug Report
COMPONENT NAME

cisco.iosxr.iosxr_facts
cisco.iosxr.iosxr_acls

ANSIBLE VERSION
ansible --version
ansible [core 2.11.3]
  config file = /etc/ansible/ansible.cfg
  configured module search path = ['/etc/ansible/modules']
  ansible python module location = /usr/local/lib/python3.9/site-packages/ansible
  ansible collection location = /etc/ansible/collections
  executable location = /usr/local/bin/ansible
  python version = 3.9.6 (default, Jul 22 2021, 09:51:47) [GCC 4.8.5 20150623 (Red Hat 4.8.5-44)]
  jinja version = 3.0.1
  libyaml = True
COLLECTION VERSION
ansible-galaxy collection list cisco.iosxr

# /etc/ansible/collections/ansible_collections
Collection  Version
----------- -------
cisco.iosxr 2.4.0

CONFIGURATION
COLLECTIONS_PATHS(/etc/ansible/ansible.cfg) = ['/etc/ansible/collections']
DEFAULT_MODULE_PATH(/etc/ansible/ansible.cfg) = ['/etc/ansible/modules']
DEFAULT_ROLES_PATH(/etc/ansible/ansible.cfg) = ['/etc/ansible/roles', '/etc/ansible/provisioning', '/etc/ansible/config_pull', '/etc/ansible/provisioning']
DISPLAY_SKIPPED_HOSTS(/etc/ansible/ansible.cfg) = False
HOST_KEY_CHECKING(/etc/ansible/ansible.cfg) = False
INTERPRETER_PYTHON(/etc/ansible/ansible.cfg) = /usr/local/bin/python3.9
PERSISTENT_CONNECT_TIMEOUT(/etc/ansible/ansible.cfg) = 30

OS / ENVIRONMENT
ios_xr#show version
Wed Aug 11 17:34:31.325 UTC
Cisco IOS XR Software, Version 6.6.3
Copyright (c) 2013-2019 by Cisco Systems, Inc.

Build Information:
 Built By     : hlo
 Built On     : Fri Dec 13 17:40:12 PST 2019
 Built Host   : iox-lnx-029
 Workspace    : /auto/srcarchive15/prod/6.6.3/ncs5500/ws
 Version      : 6.6.3
 Location     : /opt/cisco/XR/packages/

cisco NCS-5500 () processor
System uptime is 20 weeks 4 days 15 hours 12 minutes
STEPS TO REPRODUCE

using gather facts or acl module

      - name: "get IOS-XR ACLs"
        cisco.iosxr.iosxr_acls:
          state: gathered
        register: aclData
        when: ansible_network_os == "iosxr"

or

      - name: "get IOS-XR ACLs"
        cisco.iosxr.iosxr_facts:
          gather_subset: 
          - '!all'
          gather_network_resources:
          - acls
        register: aclData
        when: ansible_network_os == "iosxr"
EXPECTED RESULTS

return a Json object that looks like

{
   "ansible_facts":{
      "ansible_net_api":"cliconf",
      "ansible_net_gather_network_resources":[
         "acls"
      ],
      "ansible_net_gather_subset":[
         "default"
      ],
      "ansible_net_hostname":"hostname",
      "ansible_net_model":"NCS-5500",
      "ansible_net_python_version":"3.9.6",
      "ansible_net_system":"iosxr",
      "ansible_net_version":"6.6.3",
      "ansible_network_resources":{
         "acls":[
            {
               "acls":[
                  {
                     "aces":[
                        {
                           "destination":{
                              "host":"x.x.x.x",
                              "port_protocol":{
                                 "eq":"https"
                              }
                           },
                           "grant":"permit",
                           "protocol":"tcp",
                           "sequence":10,
                           "source":{
                              "address":"x.x.x.x",
                              "wildcard_bits":"x.x.x.x"
                           }
                        },
                        {
                           "destination":{
                              "address":"x.x.x.x",
                              "wildcard_bits":"x.x.x.x"
                           },
                           "grant":"deny",
                           "protocol":"ipv4",
                           "sequence":20,
                           "source":{
                              "address":"x.x.x.x",
                              "wildcard_bits":"x.x.x.x"
                           }
                        },
                        {
                           "destination":{
                              "any":true
                           },
                           "grant":"permit",
                           "protocol":"ipv4",
                           "sequence":30,
                           "source":{
                              "any":true
                           }
                        }
                     ],
                     "name":"ACL-NAME"
                  },
                  {
                     "afi":"ipv4"
                  }
               ]
            }
         ],
         "changed":false,
         "invocation":{
            "module_args":{
               "available_network_resources":false,
               "gather_network_resources":[
                  "acls"
               ],
               "gather_subset":[
                  "!all"
               ],
               "provider":null
            }
         }
      }
   }
}
ACTUAL RESULTS

cisco.iosxr.iosxr_acls

TASK [get IOS-XR ACLs] ***************************************************************************************************************************************************************************************
task path: 
PATH:99
The full traceback is:
  File "/tmp/ansible_cisco.iosxr.iosxr_acls_payload_wa5eqagw/ansible_cisco.iosxr.iosxr_acls_payload.zip/ansible_collections/ansible/netcommon/plugins/module_utils/network/common/facts/facts.py", line 133, in get_network_resources_facts
    inst.populate_facts(
  File "/tmp/ansible_cisco.iosxr.iosxr_acls_payload_wa5eqagw/ansible_cisco.iosxr.iosxr_acls_payload.zip/ansible_collections/cisco/iosxr/plugins/module_utils/network/iosxr/facts/acls/acls.py", line 203, in populate_facts
    obj = self.render_config(self.generated_spec, value)
  File "/tmp/ansible_cisco.iosxr.iosxr_acls_payload_wa5eqagw/ansible_cisco.iosxr.iosxr_acls_payload.zip/ansible_collections/cisco/iosxr/plugins/module_utils/network/iosxr/facts/acls/acls.py", line 239, in render_config
    acl["aces"].append(self._render_ace(ace))
  File "/tmp/ansible_cisco.iosxr.iosxr_acls_payload_wa5eqagw/ansible_cisco.iosxr.iosxr_acls_payload.zip/ansible_collections/cisco/iosxr/plugins/module_utils/network/iosxr/facts/acls/acls.py", line 436, in _render_ace
    __parse_port_protocol(
  File "/tmp/ansible_cisco.iosxr.iosxr_acls_payload_wa5eqagw/ansible_cisco.iosxr.iosxr_acls_payload.zip/ansible_collections/cisco/iosxr/plugins/module_utils/network/iosxr/facts/acls/acls.py", line 309, in __parse_port_protocol
    rendered_ace[direction]["port_protocol"] = port_protocol
fatal: []: FAILED! => {
    "changed": false,
    "invocation": {
        "module_args": {
            "config": null,
            "running_config": null,
            "state": "gathered"
        }
    },
    "msg": "'destination'"
}

cisco.iosxr.iosxr_facts

TASK [get IOS-XR ACLs] ***************************************************************************************************************************************************************************************
task path: /home/cristian.cordero/dev/interface_gather/get_inventory_interfaces/netdb2.yml:99
The full traceback is:
  File "/tmp/ansible_cisco.iosxr.iosxr_facts_payload_0chzz_hb/ansible_cisco.iosxr.iosxr_facts_payload.zip/ansible_collections/ansible/netcommon/plugins/module_utils/network/common/facts/facts.py", line 133, in get_network_resources_facts
    inst.populate_facts(
  File "/tmp/ansible_cisco.iosxr.iosxr_facts_payload_0chzz_hb/ansible_cisco.iosxr.iosxr_facts_payload.zip/ansible_collections/cisco/iosxr/plugins/module_utils/network/iosxr/facts/acls/acls.py", line 203, in populate_facts
    obj = self.render_config(self.generated_spec, value)
  File "/tmp/ansible_cisco.iosxr.iosxr_facts_payload_0chzz_hb/ansible_cisco.iosxr.iosxr_facts_payload.zip/ansible_collections/cisco/iosxr/plugins/module_utils/network/iosxr/facts/acls/acls.py", line 239, in render_config
    acl["aces"].append(self._render_ace(ace))
  File "/tmp/ansible_cisco.iosxr.iosxr_facts_payload_0chzz_hb/ansible_cisco.iosxr.iosxr_facts_payload.zip/ansible_collections/cisco/iosxr/plugins/module_utils/network/iosxr/facts/acls/acls.py", line 436, in _render_ace
    __parse_port_protocol(
  File "/tmp/ansible_cisco.iosxr.iosxr_facts_payload_0chzz_hb/ansible_cisco.iosxr.iosxr_facts_payload.zip/ansible_collections/cisco/iosxr/plugins/module_utils/network/iosxr/facts/acls/acls.py", line 309, in __parse_port_protocol
    rendered_ace[direction]["port_protocol"] = port_protocol
fatal: [edrt01.den11.viawest.net]: FAILED! => {
    "changed": false,
    "invocation": {
        "module_args": {
            "available_network_resources": false,
            "gather_network_resources": [
                "acls"
            ],
            "gather_subset": [
                "!all"
            ],
            "provider": null
        }
    },
    "msg": "'destination'"
}

IOSXR: interface not getting configured with interface module when connection is netconf (DNM)

SUMMARY

interface not getting configured with interface module when the connection is netconf

ISSUE TYPE
  • Bug Report
COMPONENT NAME

iosxr_interface

ANSIBLE VERSION
ansible 2.10.0.dev0
  config file = /home/rothakur/playbooks/collections/cisco/iosxr/ansible.cfg
  configured module search path = ['/home/rothakur/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /home/rothakur/ansible-collections/collections/ansible_collections/ansible-base/lib/ansible
  executable location = /home/rothakur/ansible-collections/collections/ansible_collections/ansible-base/bin/ansible
  python version = 3.7.9 (default, Sep 22 2020, 09:19:36) [GCC 10.2.1 20200826 (Red Hat 10.2.1-3)]

CONFIGURATION
[defaults]
INVENTORY=./inventory
collections_paths = /home/rothakur/ansible-collections/collections

[persistent_connection]
command_timeout = 100
connect_timeout = 100
connect_retry_timeout = 100
OS / ENVIRONMENT
STEPS TO REPRODUCE
- name: Merged Playbook
  hosts: iosxr-lab
  gather_facts: no
  collections:
    - cisco.iosxr
  tasks:
    - name: Merge the provided interfaces config to running-config
      iosxr_interface:
        name: 'GigabitEthernet0/0/0/0'
        description: 'interface is configures demo1'
EXPECTED RESULTS

the description should be updated with 'interface is configured demo1'

ACTUAL RESULTS
fatal: [10.8.38.70]: FAILED! => {
    "ansible_facts": {
        "discovered_interpreter_python": "/usr/bin/python"
    },
    "changed": false,
    "invocation": {
        "module_args": {
            "active": "active",
            "aggregate": null,
            "delay": 10,
            "description": "interface is configures demo1",
            "duplex": null,
            "enabled": true,
            "mtu": null,
            "name": "GigabitEthernet0/0/0/0",
            "provider": null,
            "rx_rate": null,
            "speed": null,
            "state": "present",
            "tx_rate": null
        }
    },
    "msg": "b\"'GetReply' object has no attribute 'strip'\""
}

iosxr_static_routes: Loopback and Null interfaces are not parsed

SUMMARY

The iosxr_static_routes module does not parse Loopback and Null interfaces (possibly others too) when present in an entry.

ISSUE TYPE
  • Bug Report
COMPONENT NAME

iosxr_static_routes.py

ANSIBLE VERSION
ansible [core 2.11.1]
  config file = /Users/nchakrab/demo/ansible.cfg
  configured module search path = ['/Users/nchakrab/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /Users/nchakrab/venvs/core/lib/python3.8/site-packages/ansible
  ansible collection location = /Users/nchakrab/.ansible/collections:/usr/share/ansible/collections
  executable location = /Users/nchakrab/venvs/core/bin/ansible
  python version = 3.8.7 (default, Mar  4 2021, 19:58:36) [Clang 11.0.3 (clang-1103.0.32.29)]
  jinja version = 2.11.3
  libyaml = True
CONFIGURATION

OS / ENVIRONMENT

IOS-XR 6.3.1 running on XRv9000

STEPS TO REPRODUCE

On-box config:

router static
 address-family ipv4 unicast
  0.0.0.0/0 172.31.32.1
  10.0.0.0/8 Null0 200
  11.0.0.0/8 Loopback888
  203.0.113.0/24 TenGigE0/0/0/0
 !
!
- name: "XRv - Gather existing facts from a Brownfield Environment"
  cisco.iosxr.iosxr_facts:
    gather_network_resources:
      - static_routes
EXPECTED RESULTS
static_routes:
-   address_families:
    -   afi: ipv4
        routes:
        -   dest: 0.0.0.0/0
            next_hops:
            -   forward_router_address: 172.31.32.1
        -   dest: 203.0.113.0/24
            next_hops:
            -   interface: TenGigE0/0/0/0
        -   dest: 10.0.0.0/8 
            next_hops:
            -   interface: Null0
                admin_distance: 200
        -   dest: 11.0.0.0/8 
            next_hops:
            -   interface: Loopback888
        safi: unicast
ACTUAL RESULTS
static_routes:
-   address_families:
    -   afi: ipv4
        routes:
        -   dest: 0.0.0.0/0
            next_hops:
            -   forward_router_address: 172.31.32.1
        -   dest: 203.0.113.0/24
            next_hops:
            -   interface: TenGigE0/0/0/0
        -   dest: 10.0.0.0/8 
            next_hops:
            -  admin_distance: 200
        -   dest: 11.0.0.0/8 
            next_hops:
            -   {}
        safi: unicast

Problem exists in this regex: https://github.com/ansible-collections/cisco.iosxr/blob/main/plugins/module_utils/network/iosxr/facts/static_routes/static_routes.py#L153

IOS-XR Configuration: Fails to accurately report configuration failure during pseudo-atomic operation

SUMMARY

Noticing an issue with the Ansible IOS-XR configuration module. It doesn't handle the following configuration failed message well : "% Failed to commit one or more configuration items during a pseudo-atomic operation. All changes made have been reverted. Please issue 'show configuration failed [inheritance]' from this session to view the errors". Even though no configuration was done, Ansible would report success. Running the same CLI lines on the device properly reports the error.

ISSUE TYPE
  • Bug Report
COMPONENT NAME

iosxr_config

ANSIBLE VERSION
ansible 2.9.10
  config file = /etc/ansible/ansible.cfg
  configured module search path = [u'/home/nasedora/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python2.7/site-packages/ansible
  executable location = /usr/bin/ansible
  python version = 2.7.5 (default, Jun 11 2019, 14:33:56) [GCC 4.8.5 20150623 (Red Hat 4.8.5-39)]
CONFIGURATION
<no output>
OS / ENVIRONMENT

Vendor: Cisco
Type: Router
Model: Cisco ASR 9001
Version: 6.6.3

STEPS TO REPRODUCE

The only requirement for failure is that one of the lines in the .j2 template (as shown below) attempt to use a resource that doesn't exist on the device.

 # Start block for Cisco IOS-XR
    - block:
      - name: deploy configuration - Cisco IOS-XR
        check_mode: false
        iosxr_config:
          provider: "{{ cli }}"
          src: "{{ template_loc }}"
          comment: "Ansible Deploy Config Standards PB"
          match: "none"
        register: result_config

      - name: set fact containing changes made or to be made
        set_fact:
          cli_commands_run: "{{ cli_commands_run | default([]) + result_config.commands }}"
        when: result_config.commands is defined
      when: device_os == 'cisco-ios-xr'
  # End Block
EXPECTED RESULTS

Expect the module to return failure, not changed, and should show the following message in stdout: Failed to commit one or more configuration items during a pseudo-atomic operation. All changes made have been reverted. Please issue 'show configuration failed [inheritance]' from this session to view the errors.

ACTUAL RESULTS

Module returns success, and changed, and the commands field contains all of the configuration lines, none of which are actually applied (verified by checking the configuration on the actual device).

changed: [<hostname>] => {
    "changed": true,
    "commands": [
         <all commands from .j2 template>
    ],
    "invocation": {
        "module_args": {
            "admin": false,
            "after": null,
            "backup": false,
            "backup_options": null,
            "before": null,
            "comment": "Ansible Deploy Config Standards PB",
            "config": null,
            "exclusive": false,
            "force": false,
            "host": null,
            "label": null,
            "lines": null,
            "match": "none",
            "parents": null,
            "password": null,
            "port": null,
            "provider": {
                "host": "<hostname>",
                "password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
                "port": null,
                "ssh_keyfile": null,
                "timeout": 120,
                "transport": "cli",
                "username": <username>
            },
            "replace": "line",
            "src": "<all commands from .j2 template>",
            "ssh_keyfile": null,
            "timeout": null,
            "username": null
        }
    }
}

Private module attribute moved in Ansible Core 2.11

SUMMARY

Argument spec validation has changed in Ansible Core 2.11. The following private attribute call should be changed to use the public variable:

cisco.iosxr/plugins/modules/iosxr_user.py
507:            type_checker = self._module._CHECK_ARGUMENT_TYPES_DISPATCHER[  # --> ansible.module_utils.common.parameters.DEFAULT_TYPE_VALIDATORS

The private attribute is available for backwards compatibility only.

ISSUE TYPE
  • Bug Report
COMPONENT NAME

iosxr_user.py

ANSIBLE VERSION
2.11

Replace option of config is invalid for iosxr_config

SUMMARY

Ansible raises an "invalid value" error when calling the iosrx_config module with "config" value to the replace key (similar to ansible/ansible#61631 which has been closed without being solved)

ISSUE TYPE
  • Bug Report
COMPONENT NAME

iosxr_config

ANSIBLE VERSION
ansible [core 2.11.4]
  config file = None
  configured module search path = ['/home/fabrepe/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /home/fabrepe/.local/lib/python3.9/site-packages/ansible
  ansible collection location = /home/fabrepe/.ansible/collections:/usr/share/ansible/collections
  executable location = /home/fabrepe/.local/bin/ansible
  python version = 3.9.2 (default, Feb 28 2021, 17:03:44) [GCC 10.2.1 20210110]
  jinja version = 2.11.3
  libyaml = True
COLLECTION VERSION
# /home/fabrepe/.local/lib/python3.9/site-packages/ansible_collections
Collection  Version
----------- -------
cisco.iosxr 2.4.0
CONFIGURATION
OS / ENVIRONMENT

Debian 11
cisco IOS XRv 6.1.2

STEPS TO REPRODUCE
- name: load a config from disk and replace the current config
  cisco.iosxr.iosxr_config:
    src: "{{ iosxr_conf_path }}"
    replace: config
    backup: yes
    backup_options:
      filename: "{{ iosxr_backup_filename }}"
      dir_path: "{{ iosxr_backup_path }}"
  connection: network_cli
  delegate_to: "{{ iosxr_router_address }}"
EXPECTED RESULTS

Using "replace: config" is valid and configuration included in file src applied

ACTUAL RESULTS
Loading collection cisco.ios from /home/fabrepe/.local/lib/python3.9/site-packages/ansible_collections/cisco/ios
redirecting (type: become) ansible.builtin.enable to ansible.netcommon.enable
<192.168.10.201> attempting to start connection
<192.168.10.201> using connection plugin ansible.netcommon.network_cli
Found ansible-connection at path /home/fabrepe/.local/bin/ansible-connection
<192.168.10.201> local domain socket does not exist, starting it
<192.168.10.201> control socket path is /home/fabrepe/.ansible/pc/2e3fc0e6e5
<192.168.10.201> Loading collection ansible.netcommon from /home/fabrepe/.ansible/collections/ansible_collections/ansible/netcommon
<192.168.10.201> Loading collection cisco.ios from /home/fabrepe/.local/lib/python3.9/site-packages/ansible_collections/cisco/ios
<192.168.10.201> local domain socket listeners started successfully
<192.168.10.201> loaded cliconf plugin ansible_collections.cisco.ios.plugins.cliconf.ios from path /home/fabrepe/.local/lib/python3.9/site-packages/ansible_collections/cisco/ios/plugins/cliconf/ios.py for network_os cisco.ios.ios
<192.168.10.201> ssh type is set to paramiko
<192.168.10.201>
<โ—Š.201> local domain socket path is /home/fabrepe/.ansible/pc/2e3fc0e6e5
redirecting (type: action) cisco.iosxr.iosxr_config to cisco.iosxr.iosxr
redirecting (type: action) cisco.iosxr.iosxr_config to cisco.iosxr.iosxr
<192.168.10.201> ANSIBLE_NETWORK_IMPORT_MODULES: disabled
<192.168.10.201> ANSIBLE_NETWORK_IMPORT_MODULES: module execution time may be extended
<192.168.10.201> ESTABLISH LOCAL CONNECTION FOR USER: fabrepe
<192.168.10.201> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /home/fabrepe/.ansible/tmp/ansible-local-39356232l278fxe `"&& mkdir "` echo /home/fabrepe/.ansible/tmp/ansible-local-39356232l278fxe/ansible-tmp-1630923851.1004834-3936238-105281942298889 `" && echo ansible-tmp-1630923851.1004834-3936238-105281942298889="` echo /home/fabrepe/.ansible/tmp/ansible-local-39356232l2
78fxe/ansible-tmp-1630923851.1004834-3936238-105281942298889 `" ) && sleep 0'
Using module file /home/fabrepe/.local/lib/python3.9/site-packages/ansible_collections/cisco/iosxr/plugins/modules/iosxr_config.py
<192.168.10.201> PUT /home/fabrepe/.ansible/tmp/ansible-local-39356232l278fxe/tmpq_1oldlt TO /home/fabrepe/.ansible/tmp/ansible-local-39356232l278fxe/ansible-tmp-1630923851.1004834-3936238-105281942298889/AnsiballZ_iosxr_config.py
<192.168.10.201> EXEC /bin/sh -c 'chmod u+x /home/fabrepe/.ansible/tmp/ansible-local-39356232l278fxe/ansible-tmp-1630923851.1004834-3936238-105281942298889/ /home/fabrepe/.ansible/tmp/ansible-local-39356232l278fxe/ansible-tmp-1630923851.1004834-3936238-105281942298889/AnsiballZ_iosxr_config.py && sleep 0'
<192.168.10.201> EXEC /bin/sh -c '/usr/bin/python3 /home/fabrepe/.ansible/tmp/ansible-local-39356232l278fxe/ansible-tmp-1630923851.1004834-3936238-105281942298889/AnsiballZ_iosxr_config.py && sleep 0'
<192.168.10.201> EXEC /bin/sh -c 'rm -f -r /home/fabrepe/.ansible/tmp/ansible-local-39356232l278fxe/ansible-tmp-1630923851.1004834-3936238-105281942298889/ > /dev/null 2>&1 && sleep 0'
The full traceback is:
  File "/tmp/ansible_cisco.iosxr.iosxr_config_payload_ss1ecfvy/ansible_cisco.iosxr.iosxr_config_payload.zip/ansible_collections/cisco/iosxr/plugins/modules/iosxr_config.py", line 350, in run
  File "/tmp/ansible_cisco.iosxr.iosxr_config_payload_ss1ecfvy/ansible_cisco.iosxr.iosxr_config_payload.zip/ansible/module_utils/connection.py", line 195, in __rpc__
    raise ConnectionError(to_text(msg, errors='surrogate_then_replace'), code=code)
fatal: [127.0.0.1 -> 192.168.10.201]: FAILED! => {
    "changed": false,
    "invocation": {
        "module_args": {
            "admin": false,
            "after": null,
            "backup": true,
            "backup_options": {
                "dir_path": "./target/platform_3456/iosxr/iosxr.conf.backup",
                "filename": "iosxr.conf.backup"
            },
            "before": null,
            "comment": "configured by iosxr_config",
            "config": null,
            "exclusive": false,
            "force": false,
            "label": null,
            "lines": null,
            "match": "line",
            "parents": null,
            "provider": null,
            "replace": "config",
            "src": "router bgp 65000\n ... !\n!"
        }
    },
    "msg": "'replace' value config in invalid, valid values are line, block"
}

Add available_network_resources key in iosxr_facts module

  • The key will return the list of all the RM resources available for the platform.
  • This implementation doesn't affect the current functionality of the iosxr_facts module and users can use the iosxr_facts module in the same way as they were before.

Current behavior:

---
- name: Fatch facts
  hosts: iosxr
  gather_facts: no
  collections:
    - cisco.iosxr
  
  tasks:
    - name: Get basic facts 
      iosxr_facts:
        gather_subset:
          - '!all'

output

ok: [10.8.8.69] => {
    "ansible_facts": {
        "ansible_net_api": "cliconf",
        "ansible_net_gather_network_resources": [],
        "ansible_net_gather_subset": [
            "default"
        ],
        "ansible_net_hostname": "10",
        "ansible_net_image": "bootflash:disk0/xrvr-os-mbi-6.1.3/mbixrvr-rp.vm",
        "ansible_net_model": "IOS XRv",
        "ansible_net_python_version": "3.9.2",
        "ansible_net_system": "iosxr",
        "ansible_net_version": "6.1.3[Default]",
        "ansible_network_resources": {},
        "discovered_interpreter_python": "/usr/bin/python"
    },
    "changed": false,
    "invocation": {
        "module_args": {
            "available_network_resources": false,
            "gather_network_resources": null,
            "gather_subset": [
                "!all"
            ],
            "provider": null
        }
    }
}

After implementation of available_network_resources
Sample Playbook:

---
- name: Get the list of  available resource Modules
  hosts: iosxr
  gather_facts: no
  collections:
    - cisco.iosxr
  
  tasks:
    - name: Get the list of available network resources for Cisco IOS-XR 6.1.3  and avoid fetching resource facts
      iosxr_facts:
        gather_subset:
          - '!all'
        available_network_resources: true

Result:

ok: [10.8.8.69] => {
    "ansible_facts": {
        "ansible_net_api": "cliconf",
        "ansible_net_gather_network_resources": [],
        "ansible_net_gather_subset": [
            "default"
        ],
        "ansible_net_hostname": "10",
        "ansible_net_image": "bootflash:disk0/xrvr-os-mbi-6.1.3/mbixrvr-rp.vm",
        "ansible_net_model": "IOS XRv",
        "ansible_net_python_version": "3.9.2",
        "ansible_net_system": "iosxr",
        "ansible_net_version": "6.1.3[Default]",
        "ansible_network_resources": {},
        "available_network_resources": [
            "acl_interfaces",
            "acls",
            "bgp_address_family",
            "bgp_global",
            "bgp_neighbor_address_family",
            "interfaces",
            "l2_interfaces",
            "l3_interfaces",
            "lacp",
            "lacp_interfaces",
            "lag_interfaces",
            "lldp_global",
            "lldp_interfaces",
            "ospf_interfaces",
            "ospfv2",
            "ospfv3",
            "static_routes"
        ],
        "discovered_interpreter_python": "/usr/bin/python"
    },
    "changed": false,
    "invocation": {
        "module_args": {
            "available_network_resources": true,
            "gather_network_resources": null,
            "gather_subset": [
                "!all"
            ],
            "provider": null
        }
    }
}

IOSXR_CONFIG Replace Config Not Working as Intended for NCS 5500 (7.1.2.17I) vs NCS 540 (7.2.1.34I)

SUMMARY

I am writing a playbook that will backup and replace the running config on several network devices. I was testing the replace functionality using an NCS 540 and that worked as intended. When I run the replace against an NCS 5500, it did not work and I get an error. There are 3 differences that I can tell when I run the replace: 1) the chassis 2) the OS version and 3) the running config I am using as the src.

ISSUE TYPE
  • Bug Report
COMPONENT NAME

ios_xr

ANSIBLE VERSION
ansible 2.9.9
  config file = /etc/ansible/ansible.cfg
  configured module search path = [u'/Users/Donny/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /Library/Python/2.7/site-packages/ansible
  executable location = /usr/local/bin/ansible
  python version = 2.7.16 (default, Jan 27 2020, 04:46:15) [GCC 4.2.1 Compatible Apple LLVM 10.0.1 (clang-1001.0.37.14)]
CONFIGURATION
PERSISTENT_COMMAND_TIMEOUT(/etc/ansible/ansible.cfg) = 300
OS / ENVIRONMENT

NCS 540 - 7.2.1.34I
NCS 5500 - 7.1.2.17I
Running ansible off of MacOS Mojave (10.14.6)

STEPS TO REPRODUCE
  1. Backup running config from device
  2. Make a change to the config (like adding a dummy logging configuration) and commit (commented out in the playbook below)
  3. Replace config on device with the backup config
  4. Repeat 1-3 using the NCS 540 and then again with NCS 5500
- hosts: all
  gather_facts: false
  connection: network_cli

  tasks:
    #  - name: multiline config
    #    iosxr_config:
    #      lines:
    #        - no logging 1.1.1.1 vrf management severity info
    #        - no snmp-server host 2.2.2.2 traps version 2c Br08dCasT
     - name: Backup current config (iosxr)
       iosxr_config:
         backup: yes
         backup_options:
          filename: "{{inventory_hostname}}.cfg"
       when: backup is defined and ansible_network_os == 'iosxr'
     - name: Replace config (iosxr)
       iosxr_config:
         src: /Users/Donny/backup/[config-name].cfg
         replace: config
         backup: no
         backup_options:
           filename: no.cfgs
       when: replace is defined and ansible_network_os == 'iosxr'

lab_devices:

[all:vars]
# these defaults can be overridden for any group in the [group:vars] section

[iosxr]
...
enwdnj70-srcore-A-pr01 ansible_host=IP
enwdnj70-srcore-A-pe01 ansible_host=IP
...

[iosxr:vars]
ansible_network_os=iosxr

[nxos]
...

[nxos:vars]
ansible_network_os=nxos

Example cli command when I run the playbook:
ansible-playbook test.yml -u [mySSO] --ask-pass -i lab_devices -l [device-hostname] -e replace=True
OR
ansible-playbook test.yml -u [mySSO] --ask-pass -i lab_devices -l [device-hostname] -e backup=True

EXPECTED RESULTS

Replace config to work regardless of chassis or OS version.

ACTUAL RESULTS

NSC 540:

ansible-playbook test.yml -u [mySSO] --ask-pass -i lab_devices -l enwdnj70-srcore-A-pe01 -e replace=True
SSH password: 

PLAY [all] *********************************************************************************************************************************************************************************************************

TASK [Backup current config (iosxr)] *******************************************************************************************************************************************************************************
skipping: [enwdnj70-srcore-A-pe01]

TASK [Replace config (iosxr)] **************************************************************************************************************************************************************************************
[WARNING]: Platform darwin on host enwdnj70-srcore-A-pe01 is using the discovered Python interpreter at /usr/bin/python, but future installation of another Python interpreter could change this. See
https://docs.ansible.com/ansible/2.9/reference_appendices/interpreter_discovery.html for more information.
ok: [enwdnj70-srcore-A-pe01]

PLAY RECAP *********************************************************************************************************************************************************************************************************
enwdnj70-srcore-A-pe01     : ok=1    changed=0    unreachable=0    failed=0    skipped=1    rescued=0    ignored=0 

VS
NCS 5500:

ansible-playbook test.yml -u 206587390 --ask-pass -i lab_devices -l enwdnj70-srcore-A-pr01 -e replace=True
SSH password: 

PLAY [all] *********************************************************************************************************************************************************************************************************

TASK [Backup current config (iosxr)] *******************************************************************************************************************************************************************************
skipping: [enwdnj70-srcore-A-pr01]

TASK [Replace config (iosxr)] **************************************************************************************************************************************************************************************
[WARNING]: Platform darwin on host enwdnj70-srcore-A-pr01 is using the discovered Python interpreter at /usr/bin/python, but future installation of another Python interpreter could change this. See
https://docs.ansible.com/ansible/2.9/reference_appendices/interpreter_discovery.html for more information.
fatal: [enwdnj70-srcore-A-pr01]: FAILED! => {"ansible_facts": {"discovered_interpreter_python": "/usr/bin/python"}, "changed": false, "msg": "local variable 'start_index' referenced before assignment"}

PLAY RECAP *********************************************************************************************************************************************************************************************************
enwdnj70-srcore-A-pr01     : ok=0    changed=0    unreachable=0    failed=1    skipped=1    rescued=0    ignored=0 

Before running the playbook against a different device, I change the src to be the corresponding config.

I apologize if I'm missing any additional info. Please let me know if I need to add anything else.

Thank you.

Validate unexpectedly fails in IOS XR netconf plugin (for 2.9.9)

SUMMARY

The Validate capability is something we are looking to leverage and we have it working directly via Python. However, when using the IOS XR netconf plugin (in 2.9.9), receiving errors that it is unsupported by device.

ISSUE TYPE
  • Bug Report
COMPONENT NAME

Netconf plugin for IOS XR:
plugins/netconf/iosxr.py

Note: I did see that this code is part of the main Ansible stable-2.9 branch. However, it was recommended that I instead open the issue here, as this will be the ongoing place for this plugin.

ANSIBLE VERSION
ansible 2.9.9
python version = 2.7.5 
CONFIGURATION
(no output was shown)
OS / ENVIRONMENT

Cisco IOS XR

STEPS TO REPRODUCE

Attempt to perform a task with a validate, ex:

- name: use lookup filter to provide xml configuration to be applied via netconf
connection: netconf
netconf_config:
target: "{{ netconf_target | default('candidate') }}"
error_option: "{{ netconf_error_option | default('rollback-on-error') }}"
commit: yes
validate: yes
default_operation: "merge"
content: |
<nc:config xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0">
<cdp xmlns="http://cisco.com/ns/yang/Cisco-IOS-XR-cdp-cfg">
<enable>true</enable>
</cdp>
</nc:config>
register: result
vars:
ansible_persistent_log_messages: True
EXPECTED RESULTS

Expect validate to work - the debugs show the router does support this capability:
nc:capabilityurn:ietf:params:netconf:capability:validate:1.0</nc:capability>

Additionally, a team member has confirmed this worked using ncclient directly in python.

ACTUAL RESULTS

When attempting the validate via Ansible, the following error is returned

"msg": "validate is not supported by this netconf server"

Confirmed commit fails with TypeError in IOS XR netconf plugin (for 2.9.9)

SUMMARY

Hitting a TypeError when attempting to use the confirmed commit capability with the IOX XR netconf plugin (Ansible 2.9.9). (Ansible module seems to want type=int for the timeout operation; underlying ncclient seems to need bytes or unicode.)

ISSUE TYPE
  • Bug Report
COMPONENT NAME

Netconf plugin for IOS XR:
plugins/netconf/iosxr.py

Note: I did see that this code is part of the main Ansible stable-2.9 branch. However, it was recommended that I instead open the issue here, as this will be the ongoing place for this plugin.

ANSIBLE VERSION
ansible 2.9.9
python version = 2.7.5 
CONFIGURATION
(no output was shown)
OS / ENVIRONMENT

Cisco IOS XR

STEPS TO REPRODUCE

Attempt to perform a task with a confirmed commit, ex:

- name: use lookup filter to provide xml configuration to be applied via netconf
connection: netconf
netconf_config:
target: "{{ netconf_target | default('candidate') }}"
error_option: "{{ netconf_error_option | default('rollback-on-error') }}"
commit: yes
confirm: 10
default_operation: "merge"
content: |
<nc:config xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0">
<cdp xmlns="http://cisco.com/ns/yang/Cisco-IOS-XR-cdp-cfg">
<enable>true</enable>
</cdp>
</nc:config>
register: result
vars:
ansible_persistent_log_messages: True
EXPECTED RESULTS

Expected not to receive a type error.

ACTUAL RESULTS

TypeError is received when trying to perform the confirmed commit.

Additionally, setting confirm='10' does not help, although a team mate was able to do the following with Python:
m.commit(confirmed=True, timeout='40', persist='100') succeeds.
m.commit(confirmed=True, timeout=40, persist='100') fails with the same TypeError.

Example error message is below:

  File "/usr/lib/python2.7/site-packages/ansible/utils/jsonrpc.py", line 45, in handle_request
    result = rpc_method(*args, **kwargs)
  File "/usr/lib/python2.7/site-packages/ansible/plugins/netconf/iosxr.py", line 185, in commit
    resp = self.m.commit(confirmed=confirmed, timeout=timeout, persist=persist)
  File "/usr/lib/python2.7/site-packages/ncclient/manager.py", line 231, in execute
    huge_tree=self._huge_tree).request(*args, **kwds)
  File "/usr/lib/python2.7/site-packages/ncclient/operations/edit.py", line 158, in request
    sub_ele(node, "confirm-timeout").text = timeout
  File "src/lxml/etree.pyx", line 1024, in lxml.etree._Element.text.__set__
  File "src/lxml/apihelpers.pxi", line 747, in lxml.etree._setNodeText
  File "src/lxml/apihelpers.pxi", line 735, in lxml.etree._createTextNode
  File "src/lxml/apihelpers.pxi", line 1538, in lxml.etree._utf8
TypeError: Argument must be bytes or unicode, got 'int'

iosxr_config appears to be stripping commas from jinja2 template

SUMMARY

I'm configuring a prefix-list via a jinja2 template, and when I have iosxr_config apply the template, I get "Invalid input detected at '^' marker". However, when I manually apply the template the router accepts the config. If I manually apply the config but remove the comma (,), I get the same error message the iosxr_config module throws.

I successfully use this same workflow for several other configuration sections, the only difference I can tell from this one is this one contains commas.

ISSUE TYPE
  • Bug Report
COMPONENT NAME

iosxr_config

ANSIBLE VERSION
ansible 2.9.4
  config file = /home/myuser/ansible-backbone/ansible.cfg
  configured module search path = ['/home/myuser/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /home/myuser/.local/lib/python3.6/site-packages/ansible
  executable location = /home/myuser/.local/bin/ansible
  python version = 3.6.8 (default, Sep 26 2019, 11:57:09) [GCC 4.8.5 20150623 (Red Hat 4.8.5-39)]
CONFIGURATION
DEFAULT_CALLBACK_WHITELIST(/home/myuser/ansible-backbone/ansible.cfg) = ['yaml']
DEFAULT_FORKS(/home/myuser/ansible-backbone/ansible.cfg) = 8
DEFAULT_LOAD_CALLBACK_PLUGINS(/home/myuser/ansible-backbone/ansible.cfg) = True
DEFAULT_LOG_PATH(env: ANSIBLE_LOG_PATH) = /home/myuser/ansible.log
DEFAULT_STDOUT_CALLBACK(/home/myuser/ansible-backbone/ansible.cfg) = yaml
DEPRECATION_WARNINGS(/home/myuser/ansible-backbone/ansible.cfg) = True
HOST_KEY_CHECKING(/home/myuser/ansible-backbone/ansible.cfg) = False
PERSISTENT_COMMAND_TIMEOUT(/home/myuser/ansible-backbone/ansible.cfg) = 90
PERSISTENT_CONNECT_TIMEOUT(/home/myuser/ansible-backbone/ansible.cfg) = 115
OS / ENVIRONMENT

Red Hat Enterprise Linux Server release 7.8 (Maipo)

STEPS TO REPRODUCE

$ cat /tmp/iosxr-PS_ISU_TEST_IPV4.prefix-list
192.168.1.0/24,
10.10.10.0/24
end-set

- name: 20-configure-v4-prefix-set Apply VRF V4 prefix set
  cisco.iosxr.iosxr_config:
    lines: "{{ lookup('file', '/tmp/' + ansible_network_os + '-PS_ISU_' + item.name + '_IPV4.prefix-list' ) }}"
    replace: block
    match: strict
    comment: "Configured by Ansible play '{{ ansible_play_name }}'"
    parents: "prefix-set PS_ISU_{{ item.name }}_IPV4"
  with_items:
    - "{{ vrf }}"
  register: results
  tags:
    - prefix-set
EXPECTED RESULTS

RP/0/RP0/CPU0:nr-rtr-e63-mpls-pe-wifi3#show running-config prefix-set PS_ISU_TEST_IPV4
Mon Jun 22 16:29:16.620 CDT
prefix-set PS_ISU_TEST_IPV4
192.168.1.0/24,
10.10.10.0/24
end-set
!

ACTUAL RESULTS

ansible-playbook 2.9.4
config file = /home/myuser/ansible-backbone/ansible.cfg
configured module search path = ['/home/myuser/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /home/myuser/.local/lib/python3.6/site-packages/ansible
executable location = /home/myuser/.local/bin/ansible-playbook
python version = 3.6.8 (default, Sep 26 2019, 11:57:09) [GCC 4.8.5 20150623 (Red Hat 4.8.5-39)]
Using /home/myuser/ansible-backbone/ansible.cfg as config file
setting up inventory plugins
host_list declined parsing /home/myuser/itnet-ansible-inventory-prod/inventory as it did not pass its verify_file() method
script declined parsing /home/myuser/itnet-ansible-inventory-prod/inventory as it did not pass its verify_file() method
auto declined parsing /home/myuser/itnet-ansible-inventory-prod/inventory as it did not pass its verify_file() method
Parsed /home/myuser/itnet-ansible-inventory-prod/inventory inventory source with ini plugin
Loading callback plugin yaml of type stdout, v2.0 from /home/myuser/.local/lib/python3.6/site-packages/ansible/plugins/callback/yaml.py

PLAYBOOK: ncs-prefix-list.yml *******************************************************************************************************************************************************
Positional arguments: /home/myuser/ansible-backbone/ncs-prefix-list.yml
verbosity: 4
connection: smart
timeout: 10
become_method: sudo
tags: ('all',)
inventory: ('/home/myuser/itnet-ansible-inventory-prod/inventory',)
vault_password_files: ('/srv/ansible/.ansible_vault',)
forks: 8
1 plays in /home/myuser/ansible-backbone/ncs-prefix-list.yml

PLAY [Configure NCS routers] ********************************************************************************************************************************************************
META: ran handlers
Trying secret FileVaultSecret(filename='/srv/ansible/.ansible_vault') for vault_id=default
Trying secret FileVaultSecret(filename='/srv/ansible/.ansible_vault') for vault_id=default
Trying secret FileVaultSecret(filename='/srv/ansible/.ansible_vault') for vault_id=default

TASK [ncs-prefix-list : 20-configure-v4-prefix-set Apply VRF V4 prefix set] *********************************************************************************************************
task path: /home/myuser/ansible-backbone/roles/ncs-prefix-list/tasks/main.yml:2
File lookup using /tmp/iosxr-PS_ISU_TEST_IPV4.prefix-list as file
File lookup using /tmp/iosxr-PS_ISU_TEST_IPV4.prefix-list as file
<nr-rtr-b31-mpls-pe-wifi3.tele.my.org> attempting to start connection
<nr-rtr-b31-mpls-pe-wifi3.tele.my.org> using connection plugin network_cli
<nr-rtr-e63-mpls-pe-wifi3.tele.my.org> attempting to start connection
<nr-rtr-e63-mpls-pe-wifi3.tele.my.org> using connection plugin network_cli
<nr-rtr-b31-mpls-pe-wifi3.tele.my.org> local domain socket does not exist, starting it
<nr-rtr-b31-mpls-pe-wifi3.tele.my.org> control socket path is /home/myuser/.ansible/pc/583969ae82
<nr-rtr-b31-mpls-pe-wifi3.tele.my.org> local domain socket listeners started successfully
<nr-rtr-b31-mpls-pe-wifi3.tele.my.org> loaded cliconf plugin iosxr from path /home/myuser/.local/lib/python3.6/site-packages/ansible/plugins/cliconf/iosxr.py for network_os iosxr
<nr-rtr-b31-mpls-pe-wifi3.tele.my.org>
<nr-rtr-b31-mpls-pe-wifi3.tele.my.org> local domain socket path is /home/myuser/.ansible/pc/583969ae82
<nr-rtr-e63-mpls-pe-wifi3.tele.my.org> local domain socket does not exist, starting it
<nr-rtr-e63-mpls-pe-wifi3.tele.my.org> control socket path is /home/myuser/.ansible/pc/9d4d868e38
<nr-rtr-e63-mpls-pe-wifi3.tele.my.org> local domain socket listeners started successfully
<nr-rtr-e63-mpls-pe-wifi3.tele.my.org> loaded cliconf plugin iosxr from path /home/myuser/.local/lib/python3.6/site-packages/ansible/plugins/cliconf/iosxr.py for network_os iosxr
<nr-rtr-e63-mpls-pe-wifi3.tele.my.org>
<nr-rtr-e63-mpls-pe-wifi3.tele.my.org> local domain socket path is /home/myuser/.ansible/pc/9d4d868e38
<nr-rtr-b31-mpls-pe-wifi3.tele.my.org> ESTABLISH LOCAL CONNECTION FOR USER: myuser
<nr-rtr-b31-mpls-pe-wifi3.tele.my.org> EXEC /bin/sh -c '( umask 77 && mkdir -p "echo /home/myuser/.ansible/tmp/ansible-local-41798w1zx56vv/ansible-tmp-1592861900.6055048-83158123843394" && echo ansible-tmp-1592861900.6055048-83158123843394="echo /home/myuser/.ansible/tmp/ansible-local-41798w1zx56vv/ansible-tmp-1592861900.6055048-83158123843394" ) && sleep 0'
<nr-rtr-e63-mpls-pe-wifi3.tele.my.org> ESTABLISH LOCAL CONNECTION FOR USER: myuser
<nr-rtr-e63-mpls-pe-wifi3.tele.my.org> EXEC /bin/sh -c '( umask 77 && mkdir -p "echo /home/myuser/.ansible/tmp/ansible-local-41798w1zx56vv/ansible-tmp-1592861900.7736683-213160514981160" && echo ansible-tmp-1592861900.7736683-213160514981160="echo /home/myuser/.ansible/tmp/ansible-local-41798w1zx56vv/ansible-tmp-1592861900.7736683-213160514981160" ) && sleep 0'
<nr-rtr-b31-mpls-pe-wifi3.tele.my.org> Attempting python interpreter discovery
<nr-rtr-b31-mpls-pe-wifi3.tele.my.org> 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'
<nr-rtr-e63-mpls-pe-wifi3.tele.my.org> Attempting python interpreter discovery
<nr-rtr-e63-mpls-pe-wifi3.tele.my.org> 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'
<nr-rtr-b31-mpls-pe-wifi3.tele.my.org> EXEC /bin/sh -c '/usr/bin/python && sleep 0'
<nr-rtr-e63-mpls-pe-wifi3.tele.my.org> EXEC /bin/sh -c '/usr/bin/python && sleep 0'
Using module file /home/myuser/.ansible/collections/ansible_collections/cisco/iosxr/plugins/modules/iosxr_config.py
<nr-rtr-b31-mpls-pe-wifi3.tele.my.org> PUT /home/myuser/.ansible/tmp/ansible-local-41798w1zx56vv/tmpbl6gob0h TO /home/myuser/.ansible/tmp/ansible-local-41798w1zx56vv/ansible-tmp-1592861900.6055048-83158123843394/AnsiballZ_iosxr_config.py
<nr-rtr-b31-mpls-pe-wifi3.tele.my.org> EXEC /bin/sh -c 'chmod u+x /home/myuser/.ansible/tmp/ansible-local-41798w1zx56vv/ansible-tmp-1592861900.6055048-83158123843394/ /home/myuser/.ansible/tmp/ansible-local-41798w1zx56vv/ansible-tmp-1592861900.6055048-83158123843394/AnsiballZ_iosxr_config.py && sleep 0'
<nr-rtr-b31-mpls-pe-wifi3.tele.my.org> EXEC /bin/sh -c '/usr/bin/python /home/myuser/.ansible/tmp/ansible-local-41798w1zx56vv/ansible-tmp-1592861900.6055048-83158123843394/AnsiballZ_iosxr_config.py && sleep 0'
Using module file /home/myuser/.ansible/collections/ansible_collections/cisco/iosxr/plugins/modules/iosxr_config.py
<nr-rtr-e63-mpls-pe-wifi3.tele.my.org> PUT /home/myuser/.ansible/tmp/ansible-local-41798w1zx56vv/tmpbbn50p22 TO /home/myuser/.ansible/tmp/ansible-local-41798w1zx56vv/ansible-tmp-1592861900.7736683-213160514981160/AnsiballZ_iosxr_config.py
<nr-rtr-e63-mpls-pe-wifi3.tele.my.org> EXEC /bin/sh -c 'chmod u+x /home/myuser/.ansible/tmp/ansible-local-41798w1zx56vv/ansible-tmp-1592861900.7736683-213160514981160/ /home/myuser/.ansible/tmp/ansible-local-41798w1zx56vv/ansible-tmp-1592861900.7736683-213160514981160/AnsiballZ_iosxr_config.py && sleep 0'
<nr-rtr-e63-mpls-pe-wifi3.tele.my.org> EXEC /bin/sh -c '/usr/bin/python /home/myuser/.ansible/tmp/ansible-local-41798w1zx56vv/ansible-tmp-1592861900.7736683-213160514981160/AnsiballZ_iosxr_config.py && sleep 0'
<nr-rtr-e63-mpls-pe-wifi3.tele.my.org> EXEC /bin/sh -c 'rm -f -r /home/myuser/.ansible/tmp/ansible-local-41798w1zx56vv/ansible-tmp-1592861900.7736683-213160514981160/ > /dev/null 2>&1 && sleep 0'
The full traceback is:
WARNING: The below traceback may not be related to the actual failure.
File "/tmp/ansible_cisco.iosxr.iosxr_config_payload_q7VvaB/ansible_cisco.iosxr.iosxr_config_payload.zip/ansible_collections/cisco/iosxr/plugins/module_utils/network/iosxr/iosxr.py", line 559, in load_config
label=label,
File "/tmp/ansible_cisco.iosxr.iosxr_config_payload_q7VvaB/ansible_cisco.iosxr.iosxr_config_payload.zip/ansible/module_utils/connection.py", line 185, in rpc
raise ConnectionError(to_text(msg, errors='surrogate_then_replace'), code=code)
failed: [nr-rtr-e63-mpls-pe-wifi3.tele.my.org] (item={'name': 'TEST', 'route_target': 999, 'v4_supernets': ['192.168.1.0/24', '10.10.10.0/24']}) => changed=false
ansible_facts:
discovered_interpreter_python: /usr/bin/python
ansible_loop_var: item
invocation:
module_args:
admin: false
after: null
backup: false
backup_options: null
before: null
comment: Configured by Ansible play 'Configure NCS routers'
config: null
exclusive: false
force: false
label: null
lines:
- 192.168.1.0/24
- |2-

    10.10.10.0/24
    end-set
  match: strict
  parents:
  - prefix-set PS_ISU_TEST_IPV4
  provider: null
  replace: block
  src: null

item:
name: TEST
route_target: 999
v4_supernets:
- 192.168.1.0/24
- 10.10.10.0/24
msg: |-
10.10.10.0/24
^
% Invalid input detected at '^' marker.
RP/0/RP0/CPU0:nr-rtr-e63-mpls-pe-wifi3(config-pfx)#
<nr-rtr-b31-mpls-pe-wifi3.tele.my.org> EXEC /bin/sh -c 'rm -f -r /home/myuser/.ansible/tmp/ansible-local-41798w1zx56vv/ansible-tmp-1592861900.6055048-83158123843394/ > /dev/null 2>&1 && sleep 0'
The full traceback is:
WARNING: The below traceback may not be related to the actual failure.
File "/tmp/ansible_cisco.iosxr.iosxr_config_payload_ioR6h7/ansible_cisco.iosxr.iosxr_config_payload.zip/ansible_collections/cisco/iosxr/plugins/module_utils/network/iosxr/iosxr.py", line 559, in load_config
label=label,
File "/tmp/ansible_cisco.iosxr.iosxr_config_payload_ioR6h7/ansible_cisco.iosxr.iosxr_config_payload.zip/ansible/module_utils/connection.py", line 185, in rpc
raise ConnectionError(to_text(msg, errors='surrogate_then_replace'), code=code)
failed: [nr-rtr-b31-mpls-pe-wifi3.tele.my.org] (item={'name': 'TEST', 'route_target': 999, 'v4_supernets': ['192.168.1.0/24', '10.10.10.0/24']}) => changed=false
ansible_facts:
discovered_interpreter_python: /usr/bin/python
ansible_loop_var: item
invocation:
module_args:
admin: false
after: null
backup: false
backup_options: null
before: null
comment: Configured by Ansible play 'Configure NCS routers'
config: null
exclusive: false
force: false
label: null
lines:
- 192.168.1.0/24
- |2-

    10.10.10.0/24
    end-set
  match: strict
  parents:
  - prefix-set PS_ISU_TEST_IPV4
  provider: null
  replace: block
  src: null

item:
name: TEST
route_target: 999
v4_supernets:
- 192.168.1.0/24
- 10.10.10.0/24
msg: |-
10.10.10.0/24
^
% Invalid input detected at '^' marker.
RP/0/RP0/CPU0:nr-rtr-b31-mpls-pe-wifi3(config-pfx)#

PLAY RECAP **************************************************************************************************************************************************************************
nr-rtr-b31-mpls-pe-wifi3.tele.my.org : ok=0 changed=0 unreachable=0 failed=1 skipped=0 rescued=0 ignored=0
nr-rtr-e63-mpls-pe-wifi3.tele.my.org : ok=0 changed=0 unreachable=0 failed=1 skipped=0 rescued=0 ignored=0


perfix-list facts returning {} instead of [] when facts are empty.

SUMMARY

Perfix-list which is list of dictionaries, the facts output is correct when they are populated, but when the output is empty, it shows the key-value pair as "before": {} rather than showing "before": []

ISSUE TYPE
  • Bug Report
COMPONENT NAME

iosxr_prefix-lists

ANSIBLE VERSION

COLLECTION VERSION

CONFIGURATION

OS / ENVIRONMENT
STEPS TO REPRODUCE
EXPECTED RESULTS
ACTUAL RESULTS

iosxr_banner module issue

The playbbok get timeout with multiple lines but if have only 2 lines it works, any pointer how to fix even increasing timeout doesn't make any different.

Have tried both Login & Motd options

Ansible Version - 2.8.4

name: Testing Cisco ASR9006
hosts: HOSTNAME
gather_facts: no
connection: netwotk_cli

tasks:

name: Configure the Login banner
iosxr_banner:
banner: login
text: |
line 1
line 2
line 3
state: present
@rohitthakur2590 rohitthakur2590 self-assigned this on Jul 1
@rohitthakur2590

Contributor
rohitthakur2590 commented on Jul 8
@sbanswar could you try with latest release as It works fine, following are the examples to configure timers

export ANSIBLE_PERSISTENT_CONNECT_TIMEOUT=60
[persistent_connection]
command_timeout = 100
connect_timeout = 100
connect_retry_timeout = 100
https://docs.ansible.com/ansible/latest/reference_appendices/config.html
@rohitthakur2590 rohitthakur2590 closed this on Jul 8
@sbanswar

Author
sbanswar commented 9 days ago
Hi Rohit,

What version are you suggesting , using 2.8.4? Tried with shared timers, still same error.
@sbanswar

Author
sbanswar commented 7 days ago
In addition, I don't think it's an issue with timeout, looks module doesn't able to understand the end of line hence throwing timeout error.

Commit operation is not failing for invalid input

SUMMARY

This issue is because of #135
in this PR scenario is not handled when "comment" not in error_msg

ISSUE TYPE
  • Bug Report
COMPONENT NAME

iosxr_config

ANSIBLE VERSION

CONFIGURATION

OS / ENVIRONMENT
STEPS TO REPRODUCE
  • name: commit operation should failed as configuring nbr without remote as is not allowed on iosxr
    register: result
    ignore_errors: true
    cisco.iosxr.iosxr_config:
    lines:
    - router bgp 65111
    - neighbor 10.1.1.1
    - update-source Loopback0
EXPECTED RESULTS

2021-04-19 07:23:13.894582 | ubuntu-bionic | File "/tmp/ansible_cisco.iosxr.iosxr_config_payload_SQlLfs/ansible_cisco.iosxr.iosxr_config_payload.zip/ansible/module_utils/connection.py", line 185, in rpc
2021-04-19 07:23:13.894590 | ubuntu-bionic | raise ConnectionError(to_text(msg, errors='surrogate_then_replace'), code=code)
2021-04-19 07:23:13.895518 | ubuntu-bionic | fatal: [iosxr-7.0.2]: FAILED! => {
2021-04-19 07:23:13.895541 | ubuntu-bionic | "changed": false,
2021-04-19 07:23:13.895550 | ubuntu-bionic | "invocation": {
2021-04-19 07:23:13.895558 | ubuntu-bionic | "module_args": {
2021-04-19 07:23:13.895565 | ubuntu-bionic | "admin": false,
2021-04-19 07:23:13.895573 | ubuntu-bionic | "after": null,
2021-04-19 07:23:13.895580 | ubuntu-bionic | "backup": false,
2021-04-19 07:23:13.895587 | ubuntu-bionic | "backup_options": null,
2021-04-19 07:23:13.895594 | ubuntu-bionic | "before": null,
2021-04-19 07:23:13.895601 | ubuntu-bionic | "comment": "configured by iosxr_config",
2021-04-19 07:23:13.895608 | ubuntu-bionic | "config": null,
2021-04-19 07:23:13.895616 | ubuntu-bionic | "exclusive": false,
2021-04-19 07:23:13.895623 | ubuntu-bionic | "force": false,
2021-04-19 07:23:13.895630 | ubuntu-bionic | "label": null,
2021-04-19 07:23:13.895637 | ubuntu-bionic | "lines": [
2021-04-19 07:23:13.895644 | ubuntu-bionic | "router bgp 65111",
2021-04-19 07:23:13.895651 | ubuntu-bionic | "neighbor 10.1.1.1",
2021-04-19 07:23:13.895658 | ubuntu-bionic | "update-source Loopback0"
2021-04-19 07:23:13.895665 | ubuntu-bionic | ],
2021-04-19 07:23:13.895672 | ubuntu-bionic | "match": "line",
2021-04-19 07:23:13.895679 | ubuntu-bionic | "parents": null,
2021-04-19 07:23:13.895704 | ubuntu-bionic | "provider": null,
2021-04-19 07:23:13.895711 | ubuntu-bionic | "replace": "line",
2021-04-19 07:23:13.895718 | ubuntu-bionic | "src": null
2021-04-19 07:23:13.895726 | ubuntu-bionic | }
2021-04-19 07:23:13.895734 | ubuntu-bionic | },
2021-04-19 07:23:13.895742 | ubuntu-bionic | "msg": "\r\r\n% Failed to commit one or more configuration items during a pseudo-atomic operation. All changes made have been reverted. Please issue 'show configuration failed [inheritance]' from this session to view the errors\r\nRP/0/RP0/CPU0:iosxr-7(config-bgp-nbr)#

ACTUAL RESULTS

changed: [127.0.0.1] => {
"changed": true,
"commands": [
โ€œrouter bgp 1โ€,
"neighbor 10.1.1.1",
"update-source Loopback0"
โ€œโ€
],
"diff": {
"prepared": "Building configuration...\n!! IOS XR Configuration 7.0.2\n+ router bgp 1\n+ 10.1.1.1\n+ update-source Loopback0\n!\n !\nendโ€
},
"invocation": {
"module_args": {
"admin": false,
"after": null,
"backup": false,
"backup_options": null,
"before": null,
"comment": โ€œconfigured โ€œby iosxr,
"config": null,
"exclusive": false,
"force": false,
"label": null,
"lines": [
โ€œrouter bgp 1\nโ€,
"neighbor 10.1.1.1\nโ€,
"update-source Loopback0\nโ€
],
"match": "line",
"parents": null,
"provider": null,
"replace": "line",
"src": null
}
}
}


Unable to create simple ACL with _acls module

Ansible 2.9, using latest IOSXR collection. I can run this same configuration using an NXOS module successfully.

Here is play that fails:

- name: "configure ntp acl - peer"
  cisco.iosxr.iosxr_acls:
    config:
    - afi: ipv4
      acls:
      - name: ACL-NTP-PEER
        aces:
        - sequence: 10
          grant: deny
          source:
            any: true
          destination:
            any: true
          protocol: ip
    state: overridden

Here is output from ansible-playbook

TASK [net_deploy_iosxr : configure ntp acl - peer] *************************************************************************************
task path: /home/refried.jello/ansible/roles/net_deploy_iosxr/tasks/ntp.yml:14
The full traceback is:
Traceback (most recent call last):
  File "/home/refried.jello/.ansible/tmp/ansible-local-114579sNgw_/ansible-tmp-1604089093.9-12222-566821440470/AnsiballZ_iosxr_acls.py", line 102, in <module>
    _ansiballz_main()
  File "/home/refried.jello/.ansible/tmp/ansible-local-114579sNgw_/ansible-tmp-1604089093.9-12222-566821440470/AnsiballZ_iosxr_acls.py", line 94, in _ansiballz_main
    invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)
  File "/home/refried.jello/.ansible/tmp/ansible-local-114579sNgw_/ansible-tmp-1604089093.9-12222-566821440470/AnsiballZ_iosxr_acls.py", line 40, in invoke_module
    runpy.run_module(mod_name='ansible_collections.cisco.iosxr.plugins.modules.iosxr_acls', init_globals=None, run_name='__main__', alter_sys=True)
  File "/usr/lib64/python2.7/runpy.py", line 176, in run_module
    fname, loader, pkg_name)
  File "/usr/lib64/python2.7/runpy.py", line 82, in _run_module_code
    mod_name, mod_fname, mod_loader, pkg_name)
  File "/usr/lib64/python2.7/runpy.py", line 72, in _run_code
    exec code in run_globals
  File "/tmp/ansible_cisco.iosxr.iosxr_acls_payload_UHhlJa/ansible_cisco.iosxr.iosxr_acls_payload.zip/ansible_collections/cisco/iosxr/plugins/modules/iosxr_acls.py", line 1451, in <module>
  File "/tmp/ansible_cisco.iosxr.iosxr_acls_payload_UHhlJa/ansible_cisco.iosxr.iosxr_acls_payload.zip/ansible_collections/cisco/iosxr/plugins/modules/iosxr_acls.py", line 1446, in main
  File "/tmp/ansible_cisco.iosxr.iosxr_acls_payload_UHhlJa/ansible_cisco.iosxr.iosxr_acls_payload.zip/ansible_collections/cisco/iosxr/plugins/module_utils/network/iosxr/config/acls/acls.py", line 81, in execute_module
  File "/tmp/ansible_cisco.iosxr.iosxr_acls_payload_UHhlJa/ansible_cisco.iosxr.iosxr_acls_payload.zip/ansible_collections/cisco/iosxr/plugins/module_utils/network/iosxr/config/acls/acls.py", line 126, in set_config
  File "/tmp/ansible_cisco.iosxr.iosxr_acls_payload_UHhlJa/ansible_cisco.iosxr.iosxr_acls_payload.zip/ansible_collections/cisco/iosxr/plugins/module_utils/network/iosxr/config/acls/acls.py", line 152, in set_state
  File "/tmp/ansible_cisco.iosxr.iosxr_acls_payload_UHhlJa/ansible_cisco.iosxr.iosxr_acls_payload.zip/ansible_collections/cisco/iosxr/plugins/module_utils/network/iosxr/config/acls/acls.py", line 271, in _state_overridden
  File "/tmp/ansible_cisco.iosxr.iosxr_acls_payload_UHhlJa/ansible_cisco.iosxr.iosxr_acls_payload.zip/ansible_collections/cisco/iosxr/plugins/module_utils/network/iosxr/config/acls/acls.py", line 188, in _state_replaced
KeyError: 'acls'
fatal: [spare5501.lou05]: FAILED! => {
    "changed": false,
    "module_stderr": "Traceback (most recent call last):\n  File \"/home/refried.jello/.ansible/tmp/ansible-local-114579sNgw_/ansible-tmp-1604089093.9-12222-566821440470/AnsiballZ_iosxr_acls.py\", line 102, in <module>\n    _ansiballz_main()\n  File \"/home/refried.jello/.ansible/tmp/ansible-local-114579sNgw_/ansible-tmp-1604089093.9-12222-566821440470/AnsiballZ_iosxr_acls.py\", line 94, in _ansiballz_main\n    invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)\n  File \"/home/refried.jello/.ansible/tmp/ansible-local-114579sNgw_/ansible-tmp-1604089093.9-12222-566821440470/AnsiballZ_iosxr_acls.py\", line 40, in invoke_module\n    runpy.run_module(mod_name='ansible_collections.cisco.iosxr.plugins.modules.iosxr_acls', init_globals=None, run_name='__main__', alter_sys=True)\n  File \"/usr/lib64/python2.7/runpy.py\", line 176, in run_module\n    fname, loader, pkg_name)\n  File \"/usr/lib64/python2.7/runpy.py\", line 82, in _run_module_code\n    mod_name, mod_fname, mod_loader, pkg_name)\n  File \"/usr/lib64/python2.7/runpy.py\", line 72, in _run_code\n    exec code in run_globals\n  File \"/tmp/ansible_cisco.iosxr.iosxr_acls_payload_UHhlJa/ansible_cisco.iosxr.iosxr_acls_payload.zip/ansible_collections/cisco/iosxr/plugins/modules/iosxr_acls.py\", line 1451, in <module>\n  File \"/tmp/ansible_cisco.iosxr.iosxr_acls_payload_UHhlJa/ansible_cisco.iosxr.iosxr_acls_payload.zip/ansible_collections/cisco/iosxr/plugins/modules/iosxr_acls.py\", line 1446, in main\n  File \"/tmp/ansible_cisco.iosxr.iosxr_acls_payload_UHhlJa/ansible_cisco.iosxr.iosxr_acls_payload.zip/ansible_collections/cisco/iosxr/plugins/module_utils/network/iosxr/config/acls/acls.py\", line 81, in execute_module\n  File \"/tmp/ansible_cisco.iosxr.iosxr_acls_payload_UHhlJa/ansible_cisco.iosxr.iosxr_acls_payload.zip/ansible_collections/cisco/iosxr/plugins/module_utils/network/iosxr/config/acls/acls.py\", line 126, in set_config\n  File \"/tmp/ansible_cisco.iosxr.iosxr_acls_payload_UHhlJa/ansible_cisco.iosxr.iosxr_acls_payload.zip/ansible_collections/cisco/iosxr/plugins/module_utils/network/iosxr/config/acls/acls.py\", line 152, in set_state\n  File \"/tmp/ansible_cisco.iosxr.iosxr_acls_payload_UHhlJa/ansible_cisco.iosxr.iosxr_acls_payload.zip/ansible_collections/cisco/iosxr/plugins/module_utils/network/iosxr/config/acls/acls.py\", line 271, in _state_overridden\n  File \"/tmp/ansible_cisco.iosxr.iosxr_acls_payload_UHhlJa/ansible_cisco.iosxr.iosxr_acls_payload.zip/ansible_collections/cisco/iosxr/plugins/module_utils/network/iosxr/config/acls/acls.py\", line 188, in _state_replaced\nKeyError: 'acls'\n",
    "module_stdout": "",
    "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error",
    "rc": 1

bgp_neighbor_address_family does not configure AF statements

SUMMARY

When no configurations are specified under neighbor AF, the AF command is not sent. This is valid and is mandatory for BGP peers to work.

ISSUE TYPE
  • Bug Report
COMPONENT NAME

iosxr_bgp_neighbor_address_family.py

ANSIBLE VERSION
ansible [core 2.11.1]
  config file = /Users/nchakrab/telstra_demo/ansible.cfg
  configured module search path = ['/Users/nchakrab/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /Users/nchakrab/venvs/core/lib/python3.8/site-packages/ansible
  ansible collection location = /Users/nchakrab/.ansible/collections:/usr/share/ansible/collections
  executable location = /Users/nchakrab/venvs/core/bin/ansible
  python version = 3.8.7 (default, Mar  4 2021, 19:58:36) [Clang 11.0.3 (clang-1103.0.32.29)]
  jinja version = 2.11.3
  libyaml = True
CONFIGURATION

OS / ENVIRONMENT

IOS-XR 6.3.1 running on XRv9000

STEPS TO REPRODUCE
---
- hosts: iosxr
  gather_facts: no
  tasks:
    - name: "XRv - Configure BGP Neighbor Address Family"
      cisco.iosxr.iosxr_bgp_neighbor_address_family:
        config:
          as_number: '65536'
          neighbors:
          -   address_family:
              -   afi: ipv4
                  safi: unicast
              neighbor_address: 172.31.32.213
          -   address_family:
              -   afi: ipv4
                  safi: unicast
              neighbor_address: 172.31.34.28
        state: merged
EXPECTED RESULTS

The following commands to be sent:

router bgp 65536
neighbor 172.31.34.28
address-family ipv4 unicast
neighbor 172.31.32.213
address-family ipv4 unicast
ACTUAL RESULTS

No commands are sent.

read-only user unable to run the "show version | utility head -n 20" in cliconf/iosxr.py

SUMMARY

When read-only user tried to use show command module, always showing errors:
"msg": "show version | utility head -n 20\r\n\r% This command is not authorized\r\nRP/0/RSP0/CPU0:Router#"

ISSUE TYPE
  • Bug Report
COMPONENT NAME

cisco.iosxr.iosxr_facts

ANSIBLE VERSION
ansible-playbook [core 2.12.0.dev0] 
  config file = None
  configured module search path = ['/home/runner/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/local/lib/python3.8/site-packages/ansible
  ansible collection location = /runner/requirements_collections:/home/runner/.ansible/collections:/usr/share/ansible/collections
  executable location = /usr/local/bin/ansible-playbook
  python version = 3.8.3 (default, Aug 31 2020, 16:03:14) [GCC 8.3.1 20191121 (Red Hat 8.3.1-5)]
  jinja version = 2.10.3
  libyaml = True
COLLECTION VERSION
# /usr/share/ansible/collections/ansible_collections
Collection  Version
----------- -------
cisco.iosxr 2.4.0 
CONFIGURATION
No output
OS / ENVIRONMENT

RP/0/RSP0/CPU0:Router#show version
Wed Aug 18 05:23:41.741 UTC

Cisco IOS XR Software, Version 6.0.1[Default]

STEPS TO REPRODUCE

IOS XR configured read-only user as below:
!Read-only user configured in IOS-XR router
username <>
group read-only-tg
secret 5 <>
!
service cli configuration disable usergroup read-only-tg

Running a playbook with iosxr_command always show error message: "msg": "show version | utility head -n 20\r\n\r% This command is not authorized\r\nRP/0/RSP0/CPU0:Router#"
The issue is resolved after modifying the cliconf/iosxr.py "show version | utility head -n 20" to "show version"

- name: cisco_sh_ver
  hosts: all
  gather_facts: false
  tasks:
  - name: show run on remote devices
    cisco.iosxr.iosxr_command:
     commands:
     - show run
     - show version
     - show inventory
    register: config
EXPECTED RESULTS

No error.

ACTUAL RESULTS
The full traceback is:
  File "/tmp/ansible_cisco.iosxr.iosxr_command_payload_yc6_aecr/ansible_cisco.iosxr.iosxr_command_payload.zip/ansible_collections/cisco/iosxr/plugins/module_utils/network/iosxr/iosxr.py", line 179, in get_capabilities
    capabilities = Connection(module._socket_path).get_capabilities()
  File "/tmp/ansible_cisco.iosxr.iosxr_command_payload_yc6_aecr/ansible_cisco.iosxr.iosxr_command_payload.zip/ansible/module_utils/connection.py", line 195, in __rpc__
    raise ConnectionError(to_text(msg, errors='surrogate_then_replace'), code=code)
fatal: [Router]: FAILED! => {
    "changed": false,
    "invocation": {
        "module_args": {
            "commands": [
                "show version"
            ],
            "interval": 1,
            "match": "all",
            "provider": null,
            "retries": 10,
            "wait_for": null
        }
    },
    "msg": "show version | utility head -n 20\\r\\n\\r% This command is not authorized\\r\\nRP/0/RSP0/CPU0:Router#"

Documentation examples should not be as commented lines

SUMMARY

The playbook in the example section should not be commented

https://github.com/ansible-collections/cisco.iosxr/blob/main/docs/cisco.iosxr.iosxr_logging_global_module.rst
https://github.com/ansible-collections/cisco.iosxr/blob/main/docs/cisco.iosxr.iosxr_prefix_lists_module.rst

It May not be a commented segment of code

# 
# - name: Replace BGP configuration with provided configuration
#   cisco.iosxr.iosxr_logging_global:
#     state: replaced
#     config:
#           buffered:
#             severity: errors
#           correlator:
#             buffer_size: 1024
#           files:
#             - maxfilesize: '1024'
#               name: test
#               path: test1
#               severity: info
#           hostnameprefix: test1
#           hosts:
#             - host: 1.1.1.3
#               port: default
#               severity: critical
#               vrf: default
#           ipv6:
#             dscp: af11
#           localfilesize: 1024
#           monitor:
#             severity: errors
#           tls_servers:
#             - name: test
#               tls_hostname: test2
#               trustpoint: test
#               vrf: test
#           trap:
#             severity: critical
#
# After state:
ISSUE TYPE
  • Documentation Report
COMPONENT NAME

logging_global
prefix_list

ANSIBLE VERSION

Unable to get _config module working with admin mode

I am trying to use the _config module to make changes while in admin mode on the router. The device is a Cisco NCS 5500. I have tried a variety of commands and methods and cannot get any of them working. Would love to see a working example if user-error is the only issue here. Currently just trying to get command 'clear history' to work.

Manual method

! starting off when SSH session to router, landing in the XR VM

RP/0/RP0/CPU0:ncs-sw01#
RP/0/RP0/CPU0:ncs-sw01#admin
Thu Oct 29 22:59:36.150 UTC

refried.jello connected from 127.0.0.1 using console on sysadmin-vm:0_RP0
sysadmin-vm:0_RP0# config terminal
Thu Oct  29 22:59:38.887 UTC+00:00
Entering configuration mode terminal
sysadmin-vm:0_RP0(config)# clear history
Thu Oct  29 22:59:41.235 UTC+00:00
sysadmin-vm:0_RP0(config)# exit
Thu Oct  29 22:59:42.533 UTC+00:00
sysadmin-vm:0_RP0# exit
Thu Oct  29 22:59:43.605 UTC+00:00
RP/0/RP0/CPU0:ncs-sw01#

Ansible play to attempt same

- name: "config - admin mode"
  cisco.iosxr.iosxr_config:
    lines:
      - clear history
    match: none
    admin: yes

Output from Ansible play

TASK [net_deploy_iosxr : aaa - configure user groups] ****************************************************************************************
task path: /home/refried.jello/ansible/roles/net_deploy_iosxr/tasks/aaa.yml:13
The full traceback is:
WARNING: The below traceback may *not* be related to the actual failure.
  File "/tmp/ansible_cisco.iosxr.iosxr_config_payload_KP1MVy/ansible_cisco.iosxr.iosxr_config_payload.zip/ansible_collections/cisco/iosxr/plugins/module_utils/network/iosxr/iosxr.py", line 568, in load_config
    label=label,
  File "/tmp/ansible_cisco.iosxr.iosxr_config_payload_KP1MVy/ansible_cisco.iosxr.iosxr_config_payload.zip/ansible/module_utils/connection.py", line 185, in __rpc__
    raise ConnectionError(to_text(msg, errors='surrogate_then_replace'), code=code)
fatal: [ncs-sw01]: FAILED! => {
    "changed": false,
    "invocation": {
        "module_args": {
            "admin": true,
            "after": null,
            "backup": false,
            "backup_options": null,
            "before": null,
            "comment": "configured by iosxr_config",
            "config": null,
            "exclusive": false,
            "force": false,
            "label": null,
            "lines": [
                "clear history"
            ],
            "match": "none",
            "parents": null,
            "provider": null,
            "replace": "line",
            "src": null
        }
    },
    "msg": "command timeout triggered, timeout value is 30 secs.\nSee the timeout setting options in the Network Debug and Troubleshooting Guide."
}

PLAY RECAP ***********************************************************************************************************************************
ncs-sw01            : ok=19   changed=0    unreachable=0    failed=1    skipped=13   rescued=0    ignored=1

Summary

Would love to see working example of the _config module working with admin mode. Probably worth adding to the documentation.

I am confused by the error. Why is it timing out, what is it expecting back that is not being returned? Its not the _command module that expects command output/results. Any help greatly appreciated!

Add common functionality across modules to utils.py

SUMMARY

Move common functionality across Bgp_global, bgp_af and bgp_nbr_af to utils.py

ISSUE TYPE
  • Bug Report
COMPONENT NAME

iosxr_bgp_global, iosxr_bgp_address_family,iosxr_neighbor_address_family

ANSIBLE VERSION

CONFIGURATION

OS / ENVIRONMENT
STEPS TO REPRODUCE
EXPECTED RESULTS
ACTUAL RESULTS

IOSXR: Interface is not getting configured when using interface module along with connection is Netconf

SUMMARY
ISSUE TYPE
  • Bug Report
COMPONENT NAME

iosxr_interface
Netconf plugin

ANSIBLE VERSION
  ansible 2.11.0.dev0 (devel 5ecfb19cad) last updated 2020/12/18 12:48:23 (GMT +550)
  config file = /Users/amhatre/ansible-collections/playbooks/ansible.cfg
  configured module search path = ['/Users/amhatre/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /Users/amhatre/dev-workspace/ansible/lib/ansible
  ansible collection location = /Users/amhatre/ansible-collections/collections/ansible_collections
  executable location = /Users/amhatre/dev-workspace/ansible/bin/ansible
  python version = 3.6.10 (default, Dec 16 2020, 20:36:55) [GCC Apple LLVM 12.0.0 (clang-1200.0.32.28)]
  jinja version = 2.11.2
  libyaml = False


CONFIGURATION
[defaults]
inventory=inventory
host_key_checking=False
gathering=no
interpreter_python=/Users/amhatre/ansible_venvs/netconf_issue/bin/python
collections_paths = /Users/amhatre/ansible-collections/collections/ansible_collections
#interpreter_python=/Users/amhatre/ansible_venvs/ansible_2.10/bin/python
#stdout_callback=yaml

[persistent_connection]
log_messages = True
command_timeout = 100
connect_timeout = 100
connect_retry_timeout = 100
OS / ENVIRONMENT

Device information :
Cisco IOS XR Software, Version 6.1.3[Default]

STEPS TO REPRODUCE

Use iosxr_interface module to configure description on interface

- name: configure description of iosxr interface using module iosxr_interface module
  hosts: iosxr
  tasks:
    - name: Configure Ethernet interfaces
      cisco.iosxr.iosxr_interface:
          name: GigabitEthernet0/0/0/1
          description: configured by ansible 
      connection: netconf
EXPECTED RESULTS

the description should be updated with 'configured by ansible'

ACTUAL RESULTS
The full traceback is:
  File "/var/folders/j6/fqn4v5252b9_4ck6xxq4_rqm0000gn/T/ansible_cisco.iosxr.iosxr_interface_payload_0fc7_ela/ansible_cisco.iosxr.iosxr_interface_payload.zip/ansible_collections/cisco/iosxr/plugins/module_utils/network/iosxr/iosxr.py", line 488, in get_config
    source=source, filter=config_filter, remove_ns=True
  File "/var/folders/j6/fqn4v5252b9_4ck6xxq4_rqm0000gn/T/ansible_cisco.iosxr.iosxr_interface_payload_0fc7_ela/ansible_cisco.iosxr.iosxr_interface_payload.zip/ansible_collections/ansible/netcommon/plugins/module_utils/network/common/netconf.py", line 81, in __rpc__
    to_bytes(rpc_error, errors="surrogate_then_replace")
  File "/var/folders/j6/fqn4v5252b9_4ck6xxq4_rqm0000gn/T/ansible_cisco.iosxr.iosxr_interface_payload_0fc7_ela/ansible_cisco.iosxr.iosxr_interface_payload.zip/ansible_collections/ansible/netcommon/plugins/module_utils/network/common/netconf.py", line 126, in parse_rpc_error
    raise ConnectionError(rpc_error)
fatal: [10.8.38.70]: FAILED! => {
    "changed": false,
    "invocation": {
        "module_args": {
            "active": "active",
            "aggregate": null,
            "delay": 10,
            "description": "configured by ansible netconf plugin test",
            "duplex": null,
            "enabled": true,
            "mtu": null,
            "name": "GigabitEthernet0/0/0/1",
            "provider": null,
            "rx_rate": null,
            "speed": null,
            "state": "present",
            "tx_rate": null
        }
    },
    "msg": "b\"'GetReply' object has no attribute 'strip'\""
}


IOSXR Patches Seem To Be Missing In Collection version 2.3

SUMMARY

bugfix_138 should be present in Ansible Network Collection for Cisco IOSXR version 2.2+ but seems to be absent in collection 2.3.

ISSUE TYPE
  • Bug Report
COMPONENT NAME

collections/ansible_collections/cisco/iosxr/plugins/cliconf/iosxr.py

ANSIBLE VERSION

[USER@XXXX_RHEL8 sips-cable-test]$ ansible-galaxy --version

ansible-galaxy 2.9.23

config file = /home/USER/.ansible.cfg

configured module search path = ['/home/USER/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']

ansible python module location = /usr/lib/python3.6/site-packages/ansible

executable location = /usr/bin/ansible-galaxy

python version = 3.6.8 (default, Mar 18 2021, 08:58:41) [GCC 8.4.1 20200928 (Red Hat 8.4.1-1)]

[USER@XXXX_RHEL8 sips-cable-test]$

COLLECTION VERSION

"ansible-galaxy collection list ." does not run properly, it errs out:

[USER@XXXX_RHEL8 sips-cable-test]$ ansible-galaxy collection list collections/ansible_collections/cisco.iosxr

usage: ansible-galaxy collection [-h] COLLECTION_ACTION ...

ansible-galaxy collection: error: argument COLLECTION_ACTION: invalid choice: 'list' (choose from 'init', 'build', 'publish', 'install')

[USER@XXXX_RHEL8 sips-cable-test]$ 
CONFIGURATION
[USER@XXXX_RHEL8 sips-cable-test]$ ansible-config dump --only-changed

GALAXY_IGNORE_CERTS(/home/USER/.ansible.cfg) = True

GALAXY_SERVER_LIST(/home/USER/.ansible.cfg) = ['published_repo', 'rh-certified_repo']

[USER@XXXX_RHEL8 sips-cable-test]$
OS / ENVIRONMENT

Tower Version 3.7.3
Network device NCS55A-01 running IOSXR 7.2.2

STEPS TO REPRODUCE
sips-cable-test is chosen and errs out because a comment is left.  This should not happen because the fix for this issue should be part of the 2.3 collection: https://github.com/ashwini-mhatre/cisco.iosxr/tree/bugfix_138
EXPECTED RESULTS

For network devices that do not support comments the comment should be ignored.

ACTUAL RESULTS

For network devices that do not support comments the comment is attempted to be written with the set
of changes to the network device and the device does not commit any of the changes because a comment
is used when it is not supported by IOSXR.

Inclusion of cisco.iosxr in Ansible 2.10

This collection will be included in Ansible 2.10 because it contains modules and/or plugins that were included in Ansible 2.9. Please review:

DEADLINE: 2020-08-18

The latest version of the collection available on August 18 will be included in Ansible 2.10.0, except possibly newer versions which differ only in the patch level. (For details, see the roadmap). Please release version 1.0.0 of your collection by this date! If 1.0.0 does not exist, the same 0.x.y version will be used in all of Ansible 2.10 without updates, and your 1.x.y release will not be included until Ansible 2.11 (unless you request an exception at a community working group meeting and go through a demanding manual process to vouch for backwards compatibility . . . you want to avoid this!).

Follow semantic versioning rules

Your collection versioning must follow all semver rules. This means:

  • Patch level releases can only contain bugfixes;
  • Minor releases can contain new features, new modules and plugins, and bugfixes, but must not break backwards compatibility;
  • Major releases can break backwards compatibility.

Changelogs and Porting Guide

Your collection should provide data for the Ansible 2.10 changelog and porting guide. The changelog and porting guide are automatically generated from ansible-base, and from the changelogs of the included collections. All changes from the breaking_changes, major_changes, removed_features and deprecated_features sections will appear in both the changelog and the porting guide. You have two options for providing changelog fragments to include:

  1. If possible, use the antsibull-changelog tool, which uses the same changelog fragment as the ansible/ansible repository (see the documentation).
  2. If you cannot use antsibull-changelog, you can provide the changelog in a machine-readable format as changelogs/changelog.yaml inside your collection (see the documentation of changelogs/changelog.yaml format).

If you cannot contribute to the integrated Ansible changelog using one of these methods, please provide a link to your collection's changelog by creating an issue in https://github.com/ansible-community/ansible-build-data/. If you do not provide changelogs/changelog.yml or a link, users will not be able to find out what changed in your collection from the Ansible changelog and porting guide.

Make sure your collection passes the sanity tests

Run ansible-test sanity --docker -v in the collection with the latest ansible-base or stable-2.10 ansible/ansible checkout.

Keep informed

Be sure you're subscribed to:

Questions and Feedback

If you have questions or want to provide feedback, please see the Feedback section in the collection requirements.

(Internal link to keep track of issues: ansible-collections/overview#102)

iosxr match strict with src broken

SUMMARY

without the 'match' part of the config, the addresses under the interfaces never get applied. I assume it's because there is already the same config line (though different hierarchy) elsewhere in the config.

playing round with the 'match' and 'replace' options give me the error 'match is strict but all of the following are missing: lines' but the docs tell me that src and lines are mutually exclusive.

Match: none does work, however this causes the full configuration to be applied each time, which seems like is defeating the point.

ISSUE TYPE
  • Bug Report
COMPONENT NAME

iosxr_config

ANSIBLE VERSION
ansible 2.9.6
  config file = None
  configured module search path = [u'/home/dave/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /home/dave/.local/lib/python2.7/site-packages/ansible
  executable location = /home/dave/.local/bin/ansible
  python version = 2.7.17 (default, Nov  7 2019, 10:07:09) [GCC 7.4.0]
CONFIGURATION
Nothing
OS / ENVIRONMENT

Linux ansible 4.15.0-91-generic #92-Ubuntu SMP Fri Feb 28 11:09:48 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
Cisco IOS XR Software, Version 6.6.3

STEPS TO REPRODUCE
- name: Configure IS-IS on IOS XR
  hosts: all
  connection: network_cli
 
  vars:
    net: 49.0001.0000.0000.0001.00
    interfaces:
      - name: FortyGigE0/0/0/34
        password: qwerty12345
      - name: FortyGigE0/0/0/35
        password: qwerty12345
 
  tasks:
    - name: Configure IS-IS
      iosxr_config:
        src: isis.j2
        match: strict
router isis ISIS
 is-type level-2-only
 net {{ net }}
 lsp-password keychain ISIS_DOMAIN
 address-family ipv4 unicast
  metric-style wide
 
 address-family ipv6 unicast
  metric-style wide
 
 interface Loopback0
  address-family ipv4 unicast
  address-family ipv6 unicast
 
 {% for interface in interfaces %}
 interface {{ interface.name }}
  address-family ipv4 unicast
  address-family ipv6 unicast
  circuit-type level-2-only
  point-to-point
  hello-password hmac-md5 {{ interface.password }}
 
 {% endfor %}
EXPECTED RESULTS

The full configuration should get applied.

ACTUAL RESULTS

With strict:

The full traceback is:
WARNING: The below traceback may *not* be related to the actual failure.
  File "/tmp/ansible_iosxr_config_payload_ohvbQT/ansible_iosxr_config_payload.zip/ansible/module_utils/basic.py", line 1577, in _check_required_if
    check_required_if(spec, param)
  File "/tmp/ansible_iosxr_config_payload_ohvbQT/ansible_iosxr_config_payload.zip/ansible/module_utils/common/validation.py", line 275, in check_required_if
    raise TypeError(to_native(msg))
fatal: [51.148.78.121]: FAILED! => {
    "changed": false,
    "invocation": {
        "module_args": {
            "admin": false,
            "backup": false,
            "comment": "configured by iosxr_config",
            "exclusive": false,
            "force": false,
            "match": "strict",
            "replace": "line",
            "src": "router isis ISIS\n is-type level-2-only\n net 49.0001.0000.0000.0001.00\n lsp-password keychain ISIS_DOMAIN\n address-family ipv4 unicast\n  metric-style wide\n\n address-family ipv6 unicast\n  metric-style wide\n\n interface Loopback0\n  address-family ipv4 unicast\n  address-family ipv6 unicast\n\n  interface FortyGigE0/0/0/34\n  address-family ipv4 unicast\n  address-family ipv6 unicast\n  circuit-type level-2-only\n  point-to-point\n  hello-password hmac-md5 qwerty12345\n\n  interface FortyGigE0/0/0/35\n  address-family ipv4 unicast\n  address-family ipv6 unicast\n  circuit-type level-2-only\n  point-to-point\n  hello-password hmac-md5 qwerty12345\n\n \n"
        }
    },
    "msg": "match is strict but all of the following are missing: lines"
}

With match: exact:

The full traceback is:
WARNING: The below traceback may *not* be related to the actual failure.
  File "/tmp/ansible_iosxr_config_payload_tgycVL/ansible_iosxr_config_payload.zip/ansible/module_utils/basic.py", line 1577, in _check_required_if
    check_required_if(spec, param)
  File "/tmp/ansible_iosxr_config_payload_tgycVL/ansible_iosxr_config_payload.zip/ansible/module_utils/common/validation.py", line 275, in check_required_if
    raise TypeError(to_native(msg))
fatal: [51.148.78.121]: FAILED! => {
    "changed": false,
    "invocation": {
        "module_args": {
            "admin": false,
            "backup": false,
            "comment": "configured by iosxr_config",
            "exclusive": false,
            "force": false,
            "match": "exact",
            "replace": "line",
            "src": "router isis ISIS\n is-type level-2-only\n net 49.0001.0000.0000.0001.00\n lsp-password keychain ISIS_DOMAIN\n address-family ipv4 unicast\n  metric-style wide\n\n address-family ipv6 unicast\n  metric-style wide\n\n interface Loopback0\n  address-family ipv4 unicast\n  address-family ipv6 unicast\n\n  interface FortyGigE0/0/0/34\n  address-family ipv4 unicast\n  address-family ipv6 unicast\n  circuit-type level-2-only\n  point-to-point\n  hello-password hmac-md5 qwerty12345\n\n  interface FortyGigE0/0/0/35\n  address-family ipv4 unicast\n  address-family ipv6 unicast\n  circuit-type level-2-only\n  point-to-point\n  hello-password hmac-md5 qwerty12345\n\n \n"
        }
    },
    "msg": "match is exact but all of the following are missing: lines"
}

With match: line (note that the full configuration is not applied under the interfaces)

changed: [51.148.78.121] => {
    "changed": true,
    "commands": [
        "router isis ISIS",
        "interface Loopback0",
        "interface FortyGigE0/0/0/34",
        "circuit-type level-2-only",
        "point-to-point",
        "hello-password hmac-md5 qwerty12345",
        "interface FortyGigE0/0/0/35",
        "circuit-type level-2-only",
        "point-to-point",
        "hello-password hmac-md5 qwerty12345"
    ],
    "diff": {
        "prepared": "Building configuration...\n!! IOS XR Configuration 6.6.3\n   router isis ZEN\n+   interface FortyGigE0/0/0/34\n+    circuit-type level-2-only\n+    point-to-point\n+    hello-password hmac-md5 encrypted 071E36495C1D005445415F59\n    !\n    interface FortyGigE0/0/0/35\n<-   hello-password hmac-md5 encrypted 1406050E1E10337A767B6760\n+>   hello-password hmac-md5 encrypted 00150403164F12575D72181B\n    !\n   !\nend"
    },
    "invocation": {
        "module_args": {
            "admin": false,
            "after": null,
            "backup": false,
            "backup_options": null,
            "before": null,
            "comment": "configured by iosxr_config",
            "config": null,
            "exclusive": false,
            "force": false,
            "host": null,
            "label": null,
            "lines": null,
            "match": "line",
            "parents": null,
            "password": null,
            "port": null,
            "provider": null,
            "replace": "line",
            "src": "router isis ISIS\n is-type level-2-only\n net 49.0001.0000.000.0001.00\n lsp-password keychain ISIS_DOMAIN\n address-family ipv4 unicast\n  metric-style wide\n\n address-family ipv6 unicast\n  metric-style wide\n\n interface Loopback0\n  address-family ipv4 unicast\n  address-family ipv6 unicast\n\n  interface FortyGigE0/0/0/34\n  address-family ipv4 unicast\n  address-family ipv6 unicast\n  circuit-type level-2-only\n  point-to-point\n  hello-password hmac-md5 qwerty12345\n\n  interface FortyGigE0/0/0/35\n  address-family ipv4 unicast\n  address-family ipv6 unicast\n  circuit-type level-2-only\n  point-to-point\n  hello-password hmac-md5 qwerty12345\n\n \n",
            "ssh_keyfile": null,
            "timeout": null,
            "username": null
        }
    }
}

iosxr cliconf does not issue end-set before issuing "show commit changes diff" when updating prefix-sets

SUMMARY

When updating a prefix-set using the iosxr_config module it fails with Invalid input detected at '^' marker.

ISSUE TYPE
  • Bug Report
COMPONENT NAME

iosxr_config / cliconf/iosxr.py

ANSIBLE VERSION
ansible 2.10.10
  config file = /Users/oha/src/ansible/oh-c/xrpfs/ansible.cfg
  configured module search path = ['/Users/oha/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /Users/oha/venv/py3/lib/python3.8/site-packages/ansible
  executable location = /Users/oha/venv/py3/bin/ansible
  python version = 3.8.5 (default, Jul 21 2020, 10:48:26) [Clang 11.0.3 (clang-1103.0.32.62)]
CONFIGURATION
COLLECTIONS_PATHS(/Users/oha/src/ansible/oh-c/xrpfs/ansible.cfg) = ['/Users/oha/src/ansible/oh-c/xrpfs']
DEFAULT_HOST_LIST(/Users/oha/src/ansible/oh-c/xrpfs/ansible.cfg) = ['/Users/oha/src/ansible/oh-c/xrpfs/inventory.yml']
HOST_KEY_CHECKING(/Users/oha/src/ansible/oh-c/xrpfs/ansible.cfg) = False
OS / ENVIRONMENT

Ansible Controller Mac OS 11.4. Remote device IOS XR

sRP/0/RP0/CPU0:xr01#sh ver
Thu Jun 17 05:56:48.108 UTC
Cisco IOS XR Software, Version 7.3.1
Copyright (c) 2013-2021 by Cisco Systems, Inc.
STEPS TO REPRODUCE

I have cfg.txt

prefix-set testing
  192.168.0.0/16
end-set

and playbook prefix-set.yml

---
- hosts: all
  connection: network_cli
  gather_facts: false

  tasks:
    - name: Configure
      cisco.iosxr.iosxr_config:
        src: cfg.txt

On first run, everything is fine. Prefix-set is updated.

If I add a line to cfg.txt

prefix-set testing
  192.168.0.0/16,
  10.0.0.0/8
end-set

It fails:

TASK [Configure] *********************************************************************************************************************************************
[WARNING]: Platform darwin on host xr01.demo.local is using the discovered Python interpreter at /usr/bin/python, but future installation of another Python
interpreter could change the meaning of that path. See https://docs.ansible.com/ansible/2.10/reference_appendices/interpreter_discovery.html for more
information.
fatal: [xr01.demo.local]: FAILED! => {"ansible_facts": {"discovered_interpreter_python": "/usr/bin/python"}, "changed": false, "msg": "show commit changes diff\r\n\r                                    ^\r\n% Invalid input detected at '^' marker.\r\nRP/0/RP0/CPU0:xr01(config-pfx)#"}

PLAY RECAP ***************************************************************************************************************************************************
xr01.demo.local            : ok=0    changed=0    unreachable=0    failed=1    skipped=0    rescued=0    ignored=0
EXPECTED RESULTS

That the prefix-set is updated

ACTUAL RESULTS
TASK [Configure] *********************************************************************************************************************************************
task path: /Users/oha/src/ansible/oh-c/xrpfs/prefix-set.yml:7
redirecting (type: connection) ansible.builtin.network_cli to ansible.netcommon.network_cli
redirecting (type: terminal) ansible.builtin.iosxr to cisco.iosxr.iosxr
redirecting (type: cliconf) ansible.builtin.iosxr to cisco.iosxr.iosxr
<10.20.30.103> attempting to start connection
<10.20.30.103> using connection plugin ansible.netcommon.network_cli
Found ansible-connection at path /Users/oha/venv/py3/bin/ansible-connection
<10.20.30.103> local domain socket does not exist, starting it
<10.20.30.103> control socket path is /Users/oha/.ansible/pc/5ee19dc373
<10.20.30.103> redirecting (type: connection) ansible.builtin.network_cli to ansible.netcommon.network_cli
<10.20.30.103> Loading collection ansible.netcommon from /Users/oha/src/ansible/oh-c/xrpfs/ansible_collections/ansible/netcommon
<10.20.30.103> redirecting (type: terminal) ansible.builtin.iosxr to cisco.iosxr.iosxr
<10.20.30.103> Loading collection cisco.iosxr from /Users/oha/src/ansible/oh-c/xrpfs/ansible_collections/cisco/iosxr
<10.20.30.103> redirecting (type: cliconf) ansible.builtin.iosxr to cisco.iosxr.iosxr
<10.20.30.103> local domain socket listeners started successfully
<10.20.30.103> loaded cliconf plugin ansible_collections.cisco.iosxr.plugins.cliconf.iosxr from path /Users/oha/src/ansible/oh-c/xrpfs/ansible_collections/cisco/iosxr/plugins/cliconf/iosxr.py for network_os iosxr
<10.20.30.103>
<10.20.30.103> local domain socket path is /Users/oha/.ansible/pc/5ee19dc373
redirecting (type: action) cisco.iosxr.iosxr_config to cisco.iosxr.iosxr
redirecting (type: action) cisco.iosxr.iosxr_config to cisco.iosxr.iosxr
<10.20.30.103> ANSIBLE_NETWORK_IMPORT_MODULES: disabled
<10.20.30.103> ANSIBLE_NETWORK_IMPORT_MODULES: module execution time may be extended
<10.20.30.103> ESTABLISH LOCAL CONNECTION FOR USER: oha
<10.20.30.103> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /Users/oha/.ansible/tmp/ansible-local-75429dz1wek4g `"&& mkdir "` echo /Users/oha/.ansible/tmp/ansible-local-75429dz1wek4g/ansible-tmp-1623909590.708897-75433-143120689889444 `" && echo ansible-tmp-1623909590.708897-75433-143120689889444="` echo /Users/oha/.ansible/tmp/ansible-local-75429dz1wek4g/ansible-tmp-1623909590.708897-75433-143120689889444 `" ) && sleep 0'
<xr01.demo.local> Attempting python interpreter discovery
<10.20.30.103> 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'
<xr01.demo.local> Python interpreter discovery fallback (unsupported platform for extended discovery: darwin)
Using module file /Users/oha/src/ansible/oh-c/xrpfs/ansible_collections/cisco/iosxr/plugins/modules/iosxr_config.py
<10.20.30.103> PUT /Users/oha/.ansible/tmp/ansible-local-75429dz1wek4g/tmp4018qwpq TO /Users/oha/.ansible/tmp/ansible-local-75429dz1wek4g/ansible-tmp-1623909590.708897-75433-143120689889444/AnsiballZ_iosxr_config.py
<10.20.30.103> EXEC /bin/sh -c 'chmod u+x /Users/oha/.ansible/tmp/ansible-local-75429dz1wek4g/ansible-tmp-1623909590.708897-75433-143120689889444/ /Users/oha/.ansible/tmp/ansible-local-75429dz1wek4g/ansible-tmp-1623909590.708897-75433-143120689889444/AnsiballZ_iosxr_config.py && sleep 0'
<10.20.30.103> EXEC /bin/sh -c '/usr/bin/python /Users/oha/.ansible/tmp/ansible-local-75429dz1wek4g/ansible-tmp-1623909590.708897-75433-143120689889444/AnsiballZ_iosxr_config.py && sleep 0'
<10.20.30.103> EXEC /bin/sh -c 'rm -f -r /Users/oha/.ansible/tmp/ansible-local-75429dz1wek4g/ansible-tmp-1623909590.708897-75433-143120689889444/ > /dev/null 2>&1 && sleep 0'
The full traceback is:
WARNING: The below traceback may *not* be related to the actual failure.
  File "/var/folders/94/20p3yxzd2f5b7y_7xz8w8b4m0000gn/T/ansible_cisco.iosxr.iosxr_config_payload_aTPTNx/ansible_cisco.iosxr.iosxr_config_payload.zip/ansible_collections/cisco/iosxr/plugins/module_utils/network/iosxr/iosxr.py", line 573, in load_config
    label=label,
  File "/var/folders/94/20p3yxzd2f5b7y_7xz8w8b4m0000gn/T/ansible_cisco.iosxr.iosxr_config_payload_aTPTNx/ansible_cisco.iosxr.iosxr_config_payload.zip/ansible/module_utils/connection.py", line 195, in __rpc__
    raise ConnectionError(to_text(msg, errors='surrogate_then_replace'), code=code)
[WARNING]: Platform darwin on host xr01.demo.local is using the discovered Python interpreter at /usr/bin/python, but future installation of another Python
interpreter could change the meaning of that path. See https://docs.ansible.com/ansible/2.10/reference_appendices/interpreter_discovery.html for more
information.
fatal: [xr01.demo.local]: FAILED! => {
    "ansible_facts": {
        "discovered_interpreter_python": "/usr/bin/python"
    },
    "changed": false,
    "invocation": {
        "module_args": {
            "admin": false,
            "after": null,
            "backup": false,
            "backup_options": null,
            "before": null,
            "comment": "configured by iosxr_config",
            "config": null,
            "exclusive": false,
            "force": false,
            "label": null,
            "lines": null,
            "match": "line",
            "parents": null,
            "provider": null,
            "replace": "line",
            "src": "prefix-set testing\n  192.168.0.0/16,\n  10.0.0.0/8\nend-set\n"
        }
    },
    "msg": "show commit changes diff\r\n\r                                    ^\r\n% Invalid input detected at '^' marker.\r\nRP/0/RP0/CPU0:xr01(config-pfx)#"
}

If you look at the prompt, it's still inside the "config-pfx". If i replicate this manually I get the same error:

RP/0/RP0/CPU0:xr01(config)#prefix-set testing
Thu Jun 17 06:01:01.737 UTC
% WARNING: Policy object prefix-set testing' exists! Reconfiguring it via CLI will replace current definition. Use 'abort to cancel.
RP/0/RP0/CPU0:xr01(config-pfx)#192.168.0.0/16,
RP/0/RP0/CPU0:xr01(config-pfx)#10.0.0.0/8
RP/0/RP0/CPU0:xr01(config-pfx)#show commit changes diff
                               ^
% Invalid input detected at '^' marker.

But if I issue end-set it works OK.

RP/0/RP0/CPU0:xr01(config)#show commit changes diff
Thu Jun 17 06:02:35.689 UTC
Building configuration...
!! IOS XR Configuration 7.3.1
   prefix-set testing
<-   192.168.0.0/16
+>   192.168.0.0/16,
+>   10.0.0.0/8
   end-set
   !
end

iosxr_config Loop path not found

SUMMARY

when looping on ioxr_config using the until loop, it does not reuse the template, complains that the path to the file is not found.

This is supposed to loop through on the device until it is unlocked if it is temporarily locked by another user/task. Testing done while turning the lock on, while task runs and the releasing the lock.

ISSUE TYPE
  • Bug Report
COMPONENT NAME

iosxr_config

ANSIBLE VERSION
ansible 2.9.6
  config file = /home/ssulliva/ansible.cfg
  configured module search path = [u'/home/ssulliva/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python2.7/site-packages/ansible
  executable location = /usr/bin/ansible
  python version = 2.7.5 (default, Sep 26 2019, 13:23:47) [GCC 4.8.5 20150623 (Red Hat 4.8.5-39)]
CONFIGURATION
Standard
OS / ENVIRONMENT

Tower 3.6.3 also tested cli with same version of ansible
Red Hat Enterprise Linux Server release 7.7 (Maipo)

STEPS TO REPRODUCE

use this template and commands to apply template to the router.

Template
{% for ntp in ntp_desired_state -%}
{{ ntp }}
{% endfor -%}
{% for no_ntp in ntp_to_delete -%}
no {{ no_ntp }}
{% endfor -%}

- name: Adjust NTP server
  iosxr_config:
    src: ../templates/ntp.j2
    comment: "Tower {{ tower_job_template_name }} Job {{ tower_job_id }}" # 60 caracter limitation on Cisco Side
    label: "Tower_JobID_{{ tower_job_id }}" # 30 caracter limitation on Cisco Side
  ignore_errors: yes
  register: ntp_adjust
  until: ntp_adjust is success
  retries: 10
  delay: 10
EXPECTED RESULTS

Slightly altered results, used lines instead of the config file. However expect similar results back when run

{
    "commands": [
        "ntp server vrf management 172.16.11.57"
    ],
    "_ansible_no_log": false,
    "changed": true,
    "attempts": 1,
    "invocation": {
        "module_args": {
            "comment": "Tower Basic Config on Tors Job 49239",
            "exclusive": false,
            "backup_options": null,
            "force": false,
            "after": null,
            "replace": "line",
            "host": null,
            "password": null,
            "port": null,
            "before": null,
            "src": null,
            "ssh_keyfile": null,
            "admin": false,
            "backup": false,
            "lines": [
                "ntp server vrf management 172.16.11.58",
                "ntp server vrf management 172.16.11.57",
                "\n"
            ],
            "label": "Tower_JobID_49239",
            "username": null,
            "parents": null,
            "timeout": null,
            "provider": null,
            "config": null,
            "match": "line"
        }
    },
    "diff": {
        "prepared": "Building configuration...\n!! IOS XR Configuration version = 6.3.2\n   ntp\n+   server vrf management 172.16.11.57\n   !\nend"
    }
}
ACTUAL RESULTS

Module cannot find path after first attempt

{
    "retries": 4,
    "attempts": 2,
    "_ansible_no_log": false,
    "msg": "path specified in src not found",
    "changed": false
}

All of iosxr_*_interfaces module parse interface incorrectly if the description has an interface keyword in it

SUMMARY

All of iosxr_*_interfaces module parse interface incorrectly if the description has an interface keyword in it

ISSUE TYPE
  • Bug Report
COMPONENT NAME

iosxr_*_interfaces

ANSIBLE VERSION
2.9.10 and devel
CONFIGURATION

OS / ENVIRONMENT

mac

STEPS TO REPRODUCE
EXPECTED RESULTS

The Interface gets parsed correctly and as expected and if interfaces facts are checked, the description should be displayed as this is interface for testing.

ACTUAL RESULTS

The interfaces gets parsed incorrectly and not as expected, the description is displayed as this is. Also, this is valid for all of iosxr_*_interfaces module as currently the logic in place split the retrieved config string based on interface w/o any check and that results into splitting of description interface wrongly as well


iosxr_interfaces does not work on interfaces that are not in running-config

SUMMARY
  • For interfaces that physically exists but do not have an entry in running-config, the iosxr_interfaces module does not make any changes.
  • This also means, the module cannot set "preconfigure" interfaces it those are not in running-config already.
ISSUE TYPE
  • Bug Report
COMPONENT NAME

iosxr_interfaces.py
possibly other iosxr interface modules too.

ANSIBLE VERSION

Tested against latest version of cisco.iosxr collection.

OS / ENVIRONMENT

IOS-XR 6.1.2
IOS-XR 6.1.3

STEPS TO REPRODUCE
- name: Remove interfaces from config before actual testing
  cisco.iosxr.iosxr_config: &rem
    lines:
      - no interface GigabitEthernet 0/0/0/1
      - no interface GigabitEthernet 0/0/0/2
      - no interface GigabitEthernet 0/0/0/4
    match: none        

- name: Merge base interfaces configuration
  cisco.iosxr.iosxr_interfaces:
    config:
      - name: GigabitEthernet0/0/0/1
        description: Configured by Ansible
        mtu: 110
        enabled: true
        duplex: half
      - name: GigabitEthernet0/0/0/2
        description: Configured by Ansible
        mtu: 2800
        speed: 100
        enabled: true
        duplex: full
    state: merged

The second task will return changed=False.

EXPECTED RESULTS
changed: [iosxr-02] => changed=true
  after:
  - description: Configured by Ansible
    duplex: half
    enabled: true
    mtu: 110
    name: GigabitEthernet0/0/0/1
  - description: Configured by Ansible
    duplex: full
    enabled: true
    mtu: 2800
    name: GigabitEthernet0/0/0/2
    speed: 100
  before: []
  commands:
  - interface GigabitEthernet0/0/0/1
  - description Configured by Ansible
  - mtu 110
  - duplex half
  - no shutdown
  - interface GigabitEthernet0/0/0/2
  - description Configured by Ansible
  - mtu 2800
  - speed 100
  - duplex full
  - no shutdown
ACTUAL RESULTS
ok: [iosxr-02] => changed=false
  before: []
  commands: []
  invocation:
    module_args:
      config:
      - description: Configured by Ansible
        duplex: half
        enabled: true
        mtu: 110
        name: GigabitEthernet0/0/0/1
        speed: null
      - description: Configured by Ansible
        duplex: full
        enabled: true
        mtu: 2800
        name: GigabitEthernet0/0/0/2
        speed: 100
      running_config: null
      state: merged

Facts gathering failed for junos_static_routes when routing instance configured as type forwarding

SUMMARY

Facts gathering failed for junos_static_routes when routing instance configured as type forwarding

ISSUE TYPE
  • Bug Report
COMPONENT NAME

junos_static_routes

ANSIBLE VERSION
ansible 2.10.0.dev0
  config file = /home/rothakur/ansible_playbooks/collections/network/juniper/junos/ansible.cfg
  configured module search path = ['/home/rothakur/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /home/rothakur/ansible-collections/collections/ansible_collections/ansible-base/lib/ansible
  executable location = /home/rothakur/ansible-collections/collections/ansible_collections/ansible-base/bin/ansible
  python version = 3.7.10 (default, Feb 17 2021, 00:06:19) [GCC 10.2.1 20201125 (Red Hat 10.2.1-9)]
CONFIGURATION
vagrant@vsrx# show routing-instances 
rtable1 {
    instance-type forwarding;
}
rtable101 {
    instance-type forwarding;
}
rtable102 {
    instance-type forwarding;
}
rtable22 {
    description "Routing table for inbound filter";
    instance-role access;
    instance-type forwarding;
    l2vpn-id l2vpn-id:11.22.33.44:100;
}

OS / ENVIRONMENT
STEPS TO REPRODUCE
---
- name: Gather Operation
  hosts: junos
  collections:
    - junipernetworks.junos
  tasks:
    - name: Gather static routes from running configuration
      junos_static_routes:
        state: gathered
EXPECTED RESULTS
ACTUAL RESULTS
The full traceback is:
  File "/tmp/ansible_junos_static_routes_payload_wktu4538/ansible_junos_static_routes_payload.zip/ansible_collections/ansible/netcommon/plugins/module_utils/network/common/facts/facts.py", line 133, in get_network_resources_facts
    inst.populate_facts(
  File "/tmp/ansible_junos_static_routes_payload_wktu4538/ansible_junos_static_routes_payload.zip/ansible_collections/junipernetworks/junos/plugins/module_utils/network/junos/facts/static_routes/static_routes.py", line 94, in populate_facts
    obj = self.render_config(self.generated_spec, xml)
  File "/tmp/ansible_junos_static_routes_payload_wktu4538/ansible_junos_static_routes_payload.zip/ansible_collections/junipernetworks/junos/plugins/module_utils/network/junos/facts/static_routes/static_routes.py", line 160, in render_config
    config["vrf"] = conf["routing-instances"]["instance"]["name"]
fatal: [192.168.122.212]: FAILED! => {
    "changed": false,
    "invocation": {
        "module_args": {
            "config": null,
            "running_config": null,
            "state": "gathered"
        }
    },
    "msg": "list indices must be integers or slices, not str"
}

bgp_neighbor_address family does not recognize `route-policy` commands

SUMMARY

The iosxr_neighbor_address_family does not render route-policy commands configured under neighbor AF in facts.
This is mandatory to configure EBGP peers in IOS-XR.

ISSUE TYPE
  • Bug Report
COMPONENT NAME

iosxr_bgp_neighbor_address_family.py

ANSIBLE VERSION
ansible [core 2.11.1]
  config file = /Users/nchakrab/telstra_demo/ansible.cfg
  configured module search path = ['/Users/nchakrab/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /Users/nchakrab/venvs/core/lib/python3.8/site-packages/ansible
  ansible collection location = /Users/nchakrab/.ansible/collections:/usr/share/ansible/collections
  executable location = /Users/nchakrab/venvs/core/bin/ansible
  python version = 3.8.7 (default, Mar  4 2021, 19:58:36) [Clang 11.0.3 (clang-1103.0.32.29)]
  jinja version = 2.11.3
  libyaml = True
CONFIGURATION

OS / ENVIRONMENT

IOS-XR 6.3.1 running on XRv9000

STEPS TO REPRODUCE

On box config:

RP/0/RP0/CPU0:ios#show running-config router bgp
Tue Jun 15 18:20:59.080 UTC
router bgp 65537
 bgp router-id 172.31.35.140
 address-family ipv4 unicast
 !
 neighbor 172.31.32.213
  remote-as 65536
  address-family ipv4 unicast
   route-policy pass-all in
   route-policy pass-all out
  !
 !
!
tasks:
  - cisco.iosxr.iosxr_bgp_neighbor_address_family:
      state: gathered
EXPECTED RESULTS

Facts should contain route-policy config lines as structured data.

ACTUAL RESULTS
bgp_neighbor_address_family:
    as_number: '65537'
    neighbors:
    -   address_family:
        -   afi: ipv4
            safi: unicast
        neighbor_address: 172.31.32.213

iosxr_banner module issue

The playbbok get timeout with multiple lines but if have only 2 lines it works, any pointer how to fix even I don't see option to increase timeout.
have tried both Login & Motd options

Ansible Version - 2.8.4

name: Testing Cisco ASR9006
hosts: HOSTNAME
gather_facts: no
connection: netwotk_cli

tasks:

name: Configure the Login banner
iosxr_banner:
banner: login
text: |
line 1
line 2
line 3
state: present

Add new states and fully qualified collection name in examples for the older Resource Modules

SUMMARY

Add gathered, rendered, parsed support to the following RMs:

ISSUE TYPE
  • Feature Idea

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.