This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
TASK [validate interface for admin state] *********************************************************************************************************** | |
Monday 14 December 2020 11:05:37 +0530 (0:00:01.886) 0:00:27.014 ******* | |
fatal: [nxos]: FAILED! => {"changed": false, "errors": [{"data_path": "Ethernet2/1.admin_state", "expected": "up", "found": "down", "json_path": "$.Ethernet2/1.admin_state", "message": "'down' does not match 'up'", "relative_schema": {"pattern": "up", "type": "string"}, "schema_path": "patternProperties.^.*.properties.admin_state.pattern", "validator": "pattern"}, {"data_path": "Ethernet2/10.admin_state", "expected": "up", "found": "down", "json_path": "$.Ethernet2/10.admin_state", "message": "'down' does not match 'up'", "relative_schema": {"pattern": "up", "type": "string"}, "schema_path": "patternProperties.^.*.properties.admin_state.pattern", "validator": "pattern"}], "msg": "Validation errors were found.\nAt 'patternProperties.^.*.properties.admin_state.pattern' 'down' does not |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- name: validate interface for admin state | |
ansible.utils.validate: | |
data: "{{ nxos_pyats_show_interface['parsed'] }}" | |
criteria: | |
- "{{ lookup('file', './criterias/nxos_show_interface_admin_criteria.json') | from_json }}" | |
engine: ansible.utils.jsonschema | |
ignore_errors: true | |
register: result | |
- name: print the interface names that does not satisfy the desired state |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"type": "object", | |
"patternProperties": { | |
"^.*": { | |
"type": "object", | |
"properties": { | |
"admin_state": { | |
"type": "string", | |
"pattern": "up" | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"Ethernet2/1": { | |
"admin_state": "down", | |
"auto_mdix": "off", | |
"auto_negotiate": false, | |
"bandwidth": 1000000, | |
"beacon": "off", | |
"counters": { | |
"in_bad_etype_drop": 0, | |
"in_broadcast_pkts": 0, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
- hosts: nxos | |
connection: ansible.netcommon.network_cli | |
gather_facts: false | |
vars: | |
ansible_network_os: cisco.nxos.nxos | |
ansible_user: "changeme" | |
ansible_password: "changeme" | |
tasks: | |
- name: "Fetch interface state and parse with pyats" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- hosts: "changeme" | |
gather_facts: no | |
connection: ansible.netcommon.network_cli | |
vars: | |
ansible_network_os: cisco.ios.ios | |
ansible_user: "changeme" | |
ansible_password: "changeme" | |
ansible_network_cli_ssh_type: libssh | |
tasks: | |
- name: run show version command |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from copy import deepcopy | |
from ansible.errors import AnsibleError | |
from ansible.module_utils._text import to_native | |
from ansible_collections.ansible.utils.plugins.module_utils.validator.base import ( | |
load_validator, | |
) | |
from ansible_collections.ansible.utils.plugins.module_utils.common.utils import ( | |
to_list, | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"type" : "object", | |
"patternProperties": { | |
"^[a-zA-Z]+$": { | |
"type": "object", | |
"properties": { | |
"auto_negotiate": { | |
"type": "boolean" | |
}, | |
"enabled": { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"GigabitEthernet0/0/0/0": { | |
"auto_negotiate": false, | |
"bandwidth": 1000000, | |
"bandwidth_max": 1000000, | |
"carrier_delay_up": 10, | |
"counters": { | |
"carrier_transitions": 1, | |
"in_abort": 0, | |
"in_broadcast_pkts": 0, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
intf_config = { | |
"interfaces": { | |
"interface": [ | |
{ | |
"config": { | |
"description": "configured by Ansible - 1", | |
"enabled": "True", | |
"loopback-mode": "False", | |
"mtu": "1024", | |
"name": "loopback0000", |