Using cli_parse with until directive causes error "'dict object' has no attribute 'parsed'"
akira6592 opened this issue · 0 comments
akira6592 commented
SUMMARY
ISSUE TYPE
- Bug Report
COMPONENT NAME
ANSIBLE VERSION
$ ansible --version
ansible [core 2.13.1]
COLLECTION VERSION
$ ansible-galaxy collection list ansible.utils
# /Users/akira/envs/a6/lib/python3.9/site-packages/ansible_collections
Collection Version
------------- -------
ansible.utils 2.6.1
CONFIGURATION
$ ansible-config dump --only-changed
HOST_KEY_CHECKING(/Users/akira/Documents/ansible/ansible.cfg) = False
OS / ENVIRONMENT
Cisco IOS 15.9(3)M3
STEPS TO REPRODUCE
The task is bellow:
- name: show ip ospf neighbor
ansible.utils.cli_parse:
command: show ip ospf neighbor
parser:
name: ansible.netcommon.ntc_templates
register: result_show_ip_ospf_neighbor
until:
- (result_show_ip_ospf_neighbor.parsed | length) >= 2
- result_show_ip_ospf_neighbor.parsed[1].state == 'FULL/DR'
EXPECTED RESULTS
Run show ip ospf neighbor
command until the second ospf neighbor is FULL
state.
ACTUAL RESULTS
When retrying with until directive, the value of the register variable is not as intended. And an error 'dict object' has no attribute 'parsed'
occurs.
TASK [show ip ospf neighbor] **********************************************************************************************************************************
task path: /Users/akira/Documents/ansible/ios_test.yml:10
redirecting (type: connection) ansible.builtin.network_cli to ansible.netcommon.network_cli
redirecting (type: terminal) ansible.builtin.ios to cisco.ios.ios
redirecting (type: cliconf) ansible.builtin.ios to cisco.ios.ios
FAILED - RETRYING: [ios01]: show ip ospf neighbor (3 retries left).Result was: {
"attempts": 1,
"changed": false,
"parsed": [
{
"address": "10.1.1.1",
"dead_time": "00:00:32",
"interface": "GigabitEthernet0/3",
"neighbor_id": "192.168.1.105",
"priority": "1",
"state": "FULL/DR"
}
],
"retries": 4,
"stdout": "Neighbor ID Pri State Dead Time Address Interface\n192.168.1.105 1 FULL/DR 00:00:32 10.1.1.1 GigabitEthernet0/3",
"stdout_lines": [
"Neighbor ID Pri State Dead Time Address Interface",
"192.168.1.105 1 FULL/DR 00:00:32 10.1.1.1 GigabitEthernet0/3"
]
}
fatal: [ios01]: FAILED! => {
"msg": "The conditional check '(result_show_ip_ospf_neighbor.parsed | length) >= 2' failed. The error was: error while evaluating conditional ((result_show_ip_ospf_neighbor.parsed | length) >= 2): 'dict object' has no attribute 'parsed'"
}
When displaying the value of the register variable at the time of retry, it contained an error of parameters are mutually exclusive: command|text
. But I used only command
.
- name: show ip ospf neighbor
ansible.utils.cli_parse:
command: show ip ospf neighbor
parser:
name: ansible.netcommon.ntc_templates
register: result_show_ip_ospf_neighbor
until:
- false # for debug
The result is bellow:
...omitted...
FAILED - RETRYING: [ios01]: show ip ospf neighbor (2 retries left).Result was: {
"attempts": 2,
"changed": false,
"errors": [
"parameters are mutually exclusive: command|text"
],
"msg": "argspec validation failed for cli_parse module plugin",
"retries": 4
}
...omitted...