Open calman-isu opened 4 years ago
We are having the same / very similar issue. For us it fails as soon as there 2 or more sets (community, prefix, ...), even without commas. It can be reproduced with the following basic config:
community-set cust-id-test
12:56
end-set
!
community-set services-testpf0000
12:78
end-set
!
It always fails to execute the second end-set
and stays inside the set context:
The full traceback is:
File "/tmp/ansible_iosxr_config_payload_7byniuay/ansible_iosxr_config_payload.zip/ansible/module_utils/network/iosxr/iosxr.py", line 475, in load_config
exclusive=exclusive, replace=replace, comment=comment, label=label)
File "/tmp/ansible_iosxr_config_payload_7byniuay/ansible_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: [router1]: FAILED! => {
"changed": false,
"invocation": {
"module_args": {
"admin": false,
"after": null,
"backup": false,
"backup_options": null,
"before": null,
"commands": [
"community-set cust-id-test",
" 12:34",
"end-set",
"!",
"community-set services-testpf0000",
" 12:78",
"end-set",
"!"
],
"comment": null,
"config": null,
"exclusive": false,
"force": false,
"host": null,
"label": "UL902715781-1",
"lines": [
"community-set cust-id-test",
" 12:34",
"end-set",
"!",
"community-set services-testpf0000",
" 12:78",
"end-set",
"!"
],
"match": "none",
"parents": null,
"password": null,
"port": null,
"provider": null,
"replace": "block",
"src": null,
"ssh_keyfile": null,
"timeout": null,
"username": null
}
},
"msg": "show commit changes diff\r\n\r ^\r\n% Invalid input detected at '^' marker.\r\nRP/0/RSP0/CPU0:router1(config-comm)#"
}
Ansible version: 2.9.18
Task example:
- name: set facts
local_action:
module: set_fact
configuration: "{{ lookup('file', 'config.txt').splitlines() }}"
rolloutId: "{{ 999999999 | random(start=900000000) }}"
delegate_to: localhost
run_once: yes
- name: apply config
iosxr_config:
commands: "{{ configuration }}"
label: UL{{ rolloutId }}-1
comment: null
match: none
replace: block
register: result_config
It works when applying the same config with the iosxr_command module:
- name: set facts
local_action:
module: set_fact
configuration: "{{ lookup('file', 'config.txt').splitlines() }}"
rolloutId: "{{ 999999999 | random(start=900000000) }}"
delegate_to: localhost
run_once: yes
- name: prepare command list
local_action:
module: set_fact
command_list: "{{ [ 'config' ] + configuration + [ 'commit label UL' + rolloutId + '-1', 'show configuration commit changes last 1', 'end' ] }}"
delegate_to: localhost
run_once: yes
- name: apply config
iosxr_command:
commands: "{{ command_list }}"
changed_when: True
register: result_config
Already tried different timeouts, match and replace params to no avail. What can I do to further debug this issue?
I think I've been hitting the same issue. I'm updating prefix-sets on an IOS XR 7.1.3
Reading the debug output I think the reason is that the module never sends an "end-set" before doing "show commit changes diff"
Looking at the output below, I can see that the router is in "config-pfx" mode - and if I run the "show commit changes diff" manually on the device inside prefix-set update I get "Invalid inputet detected".
2021-04-28 21:29:12,157 p=46948 u=user n=ansible | response-3: b'RP/0/RSP1/CPU0:router(config-pfx)#'
2021-04-28 21:29:12,158 p=46948 u=user n=ansible | matched error regex (terminal_stderr_re) 'b'invalid input'' from response 'b"show commit changes diff\r\n\r ^\r\n% Invalid input detected at '^' marker.\r\nRP/0/RSP1/CPU0:router(config-pfx)#"'
2021-04-28 21:29:12,158 p=46948 u=user n=ansible | matched stdout regex (terminal_stdout_re) 'b'[\\r\\n]*[\\w+\\-\\.:\\/\\[\\]]+(?:\\([^\\)]+\\)){,3}(?:>|#) ?$'' from error response 'b"show commit changes diff\r\n\r ^\r\n% Invalid input detected at '^' marker.\
\nRP/0/RSP1/CPU0:router(config-pfx)#"'
Digging a bit deeper. If I change the "show commit changes diff" to "show" in https://github.com/ansible-collections/cisco.iosxr/blob/e92ab97616fa17b71afa149788d830b74be5182d/plugins/cliconf/iosxr.py#L177 - I now get the error below.
It tries to commit the changes, without doing an end-set - and therefore commit will fail. Looks like a change in behaviour in IOS-XR 7.1 - I don't have an older version to check with.
matched cli prompt 'b'\r\n\r\n\rRP/0/RSP1/CPU0:router(config-pfx)#''
command: b'commit comment configured by iosxr_config'
response-1: b'commit comment configured by iosxr_config\r\n\r'
response-2: b" ^\r\n% Invalid input detected at '^' marker.\r\n"
@ashwini-mhatre and @NilashishC I see you're the last two comitters on https://github.com/ansible-collections/cisco.iosxr/blob/e92ab97616fa17b71afa149788d830b74be5182d/plugins/cliconf/iosxr.py - Can you confirm that the module is not doing "end-set" / "end" before trying to commit?
@oh-c I recently fix similar issue. following the the PR for the same https://github.com/ansible-collections/cisco.iosxr/pull/158 .
It always fails to execute the second end-set and stays inside the set context:
Same problem here.
Do we have any update on this?
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
COMPONENT NAME
iosxr_config
ANSIBLE VERSION
CONFIGURATION
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
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