ansible/test/integration/targets/prepare_nxos_tests/tasks/main.yml

129 lines
4 KiB
YAML
Raw Normal View History

---
- name: Enable Feature Privilege
nxos_config:
lines:
- feature privilege
connection: network_cli
ignore_errors: yes
- name: Enable Feature NXAPI
nxos_nxapi:
state: present
connection: network_cli
- name: Enable lldp
nxos_config:
lines:
- feature lldp
connection: network_cli
ignore_errors: yes
# Gather the list of interfaces on this device and make the list
# available for integration tests that need them.
#
# Usage in integration test playbook:
#
# - set_fact: testint="{{ nxos_int1 }}"
#
# - name: "Interface selected for this test"
# debug: msg="{{ testint }}"
- name: "Collect interface list"
nxos_command:
commands: ['show interface brief | json']
timeout: 60
connection: network_cli
register: intout
- set_fact: intdataraw="{{ intout.stdout_lines[0]['TABLE_interface']['ROW_interface'] }}"
- set_fact: nxos_int1="{{ intdataraw[1].interface }}"
- set_fact: nxos_int2="{{ intdataraw[2].interface }}"
- set_fact: nxos_int3="{{ intdataraw[3].interface }}"
# Get image version information for this device
- name: "Gather image version info"
nxos_command:
nxos_bfd_global / NxosCmdRef initial commit (#56317) * nxos_bfd_global: initial commit This is an initial POC with just a few commands included. The code has been written somewhat generically so that it can act as a best practices template for re-use in future modules. The implementation follows the yaml cmd_ref style to define each command's getter/setter/type/default. It supports platform-specific defaults. The basic logic is to collect all relevant data in a `cmd_ref` dict and pass that around to various methods. In the BFD case the devices don't provide JSON output so we have to screen-scrape with show runs. BFD does not support present/absent states so there is no state param. BFD has three different property types to handle. We can add add'l types as needed: - int - int_list (list of ints) - str (needs support for 'no' keyword) * Use get_capabilities to find platform type * PR comment fixes, round 1 * Minor cleanups * nxos_bfd_global: create NxosCmdRef in module_utils This commit just takes the latest bfd global code and moves the bulk of the code into new `class NxosCmdRef` in `module_utils/nxos/nxos.py`. The only remaining code in `nxos_bfd_global.py` are the calls from `main()`. * Add remaining command properties and documentation * update argument_spec * Add check for _exclude; add sanity test * Add targets files for bfd * Context and state absent updates * Add dict support to cmd_ref * Changed remaining list commands to dict usage * Add idempotence check for dict * Fix existing overwrite bug * Move pattern matching logic into its own method * add support for 'command: absent' * Add `get_platform_shortname`; update BFD platform-specific settings * /absent/deleted/ * /sh/show/ in prepare_nxos_tests * add dict check to get_platform_shortname * Add normalize_defaults() * UTs for bfd_global * support yaml for both py2/py3 * update cmd_ref doc header * Fix python2.6 incompatibility with dict comprehensions * Fix bfd_global doc header (yaml syntax fail) * more shippable fixes * yet more shippable fixes * shippable: remove r' ' wrappers * docfix - remove ':' * escape regex ctl chars in yaml table * remove extra blank lines * Fix str(None) issue * Command context updates * import PY2,PY3 instead of import sys * fix ordereddict import & parent_context * try/except for yaml import * fix import issue for ordereddict * remove epdb * nxosCmdRef_import_check() workaround for shippable * fix PEP ws errors
2019-06-06 12:22:55 +02:00
commands: ['show version | json']
connection: network_cli
register: nxos_version_output
- set_fact: image_version="{{ nxos_version_output.stdout[0]['kickstart_ver_str'] }}"
# Get platform information for this device
#
# Usage in integration test playbook:
#
# - name: "nxos platform "
# debug: msg="{{ platform }}"
#
- name: "Gather platform info"
nxos_command:
nxos_bfd_global / NxosCmdRef initial commit (#56317) * nxos_bfd_global: initial commit This is an initial POC with just a few commands included. The code has been written somewhat generically so that it can act as a best practices template for re-use in future modules. The implementation follows the yaml cmd_ref style to define each command's getter/setter/type/default. It supports platform-specific defaults. The basic logic is to collect all relevant data in a `cmd_ref` dict and pass that around to various methods. In the BFD case the devices don't provide JSON output so we have to screen-scrape with show runs. BFD does not support present/absent states so there is no state param. BFD has three different property types to handle. We can add add'l types as needed: - int - int_list (list of ints) - str (needs support for 'no' keyword) * Use get_capabilities to find platform type * PR comment fixes, round 1 * Minor cleanups * nxos_bfd_global: create NxosCmdRef in module_utils This commit just takes the latest bfd global code and moves the bulk of the code into new `class NxosCmdRef` in `module_utils/nxos/nxos.py`. The only remaining code in `nxos_bfd_global.py` are the calls from `main()`. * Add remaining command properties and documentation * update argument_spec * Add check for _exclude; add sanity test * Add targets files for bfd * Context and state absent updates * Add dict support to cmd_ref * Changed remaining list commands to dict usage * Add idempotence check for dict * Fix existing overwrite bug * Move pattern matching logic into its own method * add support for 'command: absent' * Add `get_platform_shortname`; update BFD platform-specific settings * /absent/deleted/ * /sh/show/ in prepare_nxos_tests * add dict check to get_platform_shortname * Add normalize_defaults() * UTs for bfd_global * support yaml for both py2/py3 * update cmd_ref doc header * Fix python2.6 incompatibility with dict comprehensions * Fix bfd_global doc header (yaml syntax fail) * more shippable fixes * yet more shippable fixes * shippable: remove r' ' wrappers * docfix - remove ':' * escape regex ctl chars in yaml table * remove extra blank lines * Fix str(None) issue * Command context updates * import PY2,PY3 instead of import sys * fix ordereddict import & parent_context * try/except for yaml import * fix import issue for ordereddict * remove epdb * nxosCmdRef_import_check() workaround for shippable * fix PEP ws errors
2019-06-06 12:22:55 +02:00
commands: ['show inventory | json']
connection: network_cli
register: nxos_inventory_output
- set_fact: platform="{{ nxos_inventory_output.stdout_lines[0]['TABLE_inv']['ROW_inv'][0]['productid'].split('-')[0] }}"
- set_fact: chassis_type="{{ nxos_inventory_output.stdout_lines[0]['TABLE_inv']['ROW_inv'][0]['productid'].split('-')[1] }}"
# Check if platform is fretta
- set_fact: fretta={% for row in nxos_inventory_output.stdout_lines[0]['TABLE_inv']['ROW_inv'] if '-R' in row['productid'] %}"true"{% endfor %}
when: platform is match("N9K|N3K")
# Set platform to N3K-F for fretta
- set_fact: platform="N3K-F"
when: ( platform is match("N3K")) and ( fretta is search("true"))
# Set platform to N9K-F for fretta
- set_fact: platform="N9K-F"
when: ( platform is match("N9K")) and ( fretta is search("true"))
# Check if platform is titanium
- set_fact: titanium="false"
- set_fact: titanium={% for row in nxos_inventory_output.stdout_lines[0]['TABLE_inv']['ROW_inv'] if 'NX-OSv' in row['desc']%}"true"{% endfor %}
when: platform is match("N7K")
# Set platform to N35 for N3k-35xx
- set_fact: platform="N35"
when: ( chassis_type is search("C35"))
# Set platform to N35NG for N3k-35xx running image version
# 7.0(3)I7 or later. NG(Next Gen)
- set_fact: platform="N35NG"
when: ( chassis_type is search("C35")) and image_version is search("7.0\(3\)I7")
# Set platform to N3L(N3K Legacy) for C3048 platform.
- set_fact: platform="N3L"
when: ( chassis_type is search("C3048"))
# Create matrix of simple keys based on platform
# and image version for use within test playbooks.
- set_fact: imagetag=""
- set_fact: imagemr=""
# Examples
# 8.0(1)
# 7.3(0)D1(1)
# 7.0(3)IHD8(1)
- set_fact: major_version="{{ image_version[0:3] }}"
- set_fact: imagetag="{{ image_version[0:3] }}"
when: image_version is search("\d\.\d\(\d\)")
- set_fact: imagetag="{{ image_version[6:8] }}"
when: image_version is search("\d\.\d\(\d\)\S\S\(\d\)")
- set_fact: imagetag="{{ image_version[6:10] }}"
when: image_version is search("\d\.\d\(\d\)\S\S\S\S\(\d\)")
- set_fact: imagemr="{{ image_version[4:5] }}"
when: image_version is search("\d\.\d\(\d\)")
- set_fact: imagemr="{{ image_version[9:10] }}"
when: image_version is search("\d\.\d\(\d\)\S\S\(\d\)")
- set_fact: imagemr="{{ image_version[11:12] }}"
when: image_version is search("\d\.\d\(\d\)\S\S\S\S\(\d\)")
- debug: msg="IMAGE VERSION {{ image_version }}"
- debug: msg="IMAGE TAG {{ imagetag }}"
- debug: msg="IMAGE MR {{ imagemr }}"
- set_fact: ipv6_supported="true"
- set_fact: ipv6_supported="false"
when: platform is match("N35")