Skip to content

How to pass ansible variables to jsnapy test files? #390

@chuegel

Description

@chuegel

Description of Issue/Question

How to pass ansible variables to jsnapy test files?

Setup

(Please provide relevant configs, xml snapshots and related files (Be sure to remove sensitive info).)
jsnapy is installed as part of the juniper.device collection

Steps to Reproduce Issue

(Include debug logs if possible and relevant. Error trace would be helpful too)
Consider this inventory:

[all:vars]
bgp_total-prefix-count: 3000

[MX104]
10.10.10.1

task:

---
- name: check BGP on "{{ inventory_hostname }}"
  juniper.device.jsnapy:
    port: "{{ netconf_port }}"
    dir: "{{ playbook_dir }}/testfiles/"
    test_files: test_bgp.yml
    action: snapcheck
  register: result_pre_bgp

testfile:

---
tests_include:
  - bgp_summary
  - bgp_neighbor

bgp_summary:
  - rpc: get-bgp-summary-information
  - item:
      xpath: '//bgp-rib'
      tests:
        - is-gt: total-prefix-count, "{{ bgp_total-prefix-count }}"
          err: "Test Failed!! value of total-prefix-count is not greater then "{{ bgp_total-prefix-count }}", it is equal to <{{post['total-prefix-count']}}>"
          info: "Test succeeded!! value of total-prefix-count is not greater then "{{ bgp_total-prefix-count }}", it is equal to <{{post['total-prefix-count']}}>"

But jsnapy throws an error: Complete Message: could not convert string to float: '"{{ bgp_total-prefix-count }}"'
How can I pass ansible variables to jsnapy test files?

Versions Report

(Provided by running jsnapy --version. Please also mention python version.)

pip list | grep jsnapy
jsnapy                1.3.6

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions