ansible-junos-stdlib icon indicating copy to clipboard operation
ansible-junos-stdlib copied to clipboard

juniper.device.jsnapy fails with config_file option and juniper.device.pyez

Open chidanandpujar opened this issue 8 months ago • 1 comments

Issue Type

Module Name

juniper.device.jsnapy

juniper.device collection and Python libraries version

Collection                               Version
---------------------------------------- -------
ansible.netcommon                        4.1.0  
ansible.utils                            2.8.0  
juniper.device                           1.0.5  

jsnapy                1.3.8.dev0

junos-eznc            2.7.1+9.ga64698b

OS / Environment

JUNOS Evolved

Summary

juniper.device.jsnapy fails with config_file option and juniper.device.pyez

Steps to reproduce

cat TEST_FILES/jsnapy_main.yml 
tests:
  - TEST_FILES/test_interface.yml 


cat TEST_FILES/test_interface.yml 
tests_include:
  - test_interface

# use '/' in your test cases apart from xpath if u want to search all elements irrespective of hierarchy, ex: in id if u use /name instead of name
# then it will search in all the names in given xpath irrespective of their position
# for simple, one test using command

test_interface:
  - command: show interfaces terse 
  - iterate:
      xpath: '//physical-interface'
      id: './name'
      tests:
        - no-diff: oper-status       # element in which test is performed
          err: "Test Failed!! oper-status  got changed, before it was <{{pre['oper-status']}}>, now it is <{{post['oper-status']}}>"
          info: "oper-status is same before it was <{{pre['oper-status']}}>, now it is <{{post['oper-status']}}>"

        - list-not-less: oper-status
          err: "name list changed, oper-state: <{{pre['oper-state']}}> with name <{{id_0}}> is not present in post-snap"
          info: "name list is same, oper-state is present in pre-snap: <{{pre['oper-status']}}> and post-snap: <{{post['oper-status']}}>"

        - list-not-more: name
          err: "<{{post['name']}}> name is not present in pre snapshot"
          info: "name is same, before it was <{{pre['name']}}>, now it is <{{post['name']}}>"


 cat pb.config_file_test_issue.yml 
---
- name: Test juniper.device.jsnapy module
  hosts: all
  gather_facts: false
  tasks:
##################################################
####    TEST 4                                  ##
##################################################
    - name: "TEST 4 - SNAP_PRE"
      juniper.device.jsnapy:
        config_file: TEST_FILES/jsnapy_main.yml 
        action: snap_pre
      register: test4
      ignore_errors: true
      tags: [test4]

    - debug: var=test4

    - name: Check TEST 4
      ansible.builtin.assert:
        that:
          - test4.msg == "The snap_pre action successfully executed."
      tags: [test4]

ansible-playbook pb.config_file_test_issue.yml 

PLAY [Test juniper.device.jsnapy module] **********************************************************************************************************************************

TASK [TEST 4 - SNAP_PRE] **************************************************************************************************************************************************
<unknown>:1812: SyntaxWarning: invalid escape sequence '\*'
ok: [pyez_connection_testcases]

TASK [debug] **************************************************************************************************************************************************************
ok: [pyez_connection_testcases] => {
    "test4": {
        "action": "snap_pre",
        "changed": false,
        "failed": false,
        "msg": "The snap_pre action successfully executed."
    }
}

TASK [Check TEST 4] *******************************************************************************************************************************************************
ok: [pyez_connection_testcases] => {
    "changed": false,
    "msg": "All assertions passed"
}

PLAY RECAP ****************************************************************************************************************************************************************
pyez_connection_testcases  : ok=3    changed=0    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0   

snapshot files are not created :


ls ~/ansible_jsnapy_issue/venv/etc/jsnapy/snapshots/
README


Expected results

snapshot files gets created .

ls ~/ansible_jsnapy_issue/venv/etc/jsnapy/snapshots/
10.220.24.28_PRE_show_interfaces_terse.xml  README

Actual results

ls ~/ansible_jsnapy_issue/venv/etc/jsnapy/snapshots/
README

chidanandpujar avatar Jun 17 '24 05:06 chidanandpujar