jsnapy¶
Execute JSNAPy tests on a Junos device
Synopsis¶
Execute Junos SNAPshot Adminsitrator (JSNAPy) tests against a Junos device. JSNAPy is documented on Github and this Day One Book
This module only reports
failed
if the module encounters an error and fails to execute the JSNAPy tests. If does NOT reportfailed
if one or more of the JSNAPy tests fail. To check the test results, register the module’s response and use the assert module to verify the expected result in the response. (See Examples.)A callback plugin which formats and prints JSNAPy test results for human consumption is also available. This callback plugin is enabled by adding
callback_whitelist = jsnapy
to the Ansible configuration file.
Requirements¶
The following software packages must be installed on hosts that execute this module:
junos-eznc >= 2.5.2
Python >= 3.5
Module-specific Options¶
The following options may be specified for this module:
parameter | type | required | default | choices | comments |
---|---|---|---|---|---|
action |
str | yes | none |
|
The JSNAPy action to perform.
|
config_file |
path | no | none |
The filename of a JSNAPy configuration file (in YAML format). The test_files option and the config_file option are mutually exclusive. Either the test_files option or the config_file option is required.
|
|
dir |
path | no | /etc/jsnapy/testfiles |
The path to the directory containing the JSNAPy test file(s) specified by the test_files option or the JSNAPy configuration file specified by the config_file option.
aliases: directory
|
|
test_files |
list of path | no | none |
The filename of file(s) in the dir directory. Each file contains JSNAPy test case definitions. The test_files option and the config_file option are mutually exclusive. Either the test_files option or the config_file option is required.
|
Examples¶
---
- name: Examples of jsnapy
hosts: junos-all
connection: local
gather_facts: no
collections:
- juniper.device
tasks:
- name: JUNOS Post Checklist
jsnapy:
action: "snap_post"
config_file: "first_test.yml"
logfile: "migration_post.log"
register: test1
- name: Verify all JSNAPy tests passed
assert:
that:
- "test1.passPercentage == 100"
- name: Print the full test response
debug:
var: test1
- name: Test based on a test_file directly
jsnapy:
action: "snapcheck"
test_files: "tests/test_junos_interface.yaml"
register: test2
- name: Verify all JSNAPy tests passed
assert:
that:
- "test2.passPercentage == 100"
- name: Print the full test response
debug:
var: test2
- name: "Collect Pre Snapshot"
jsnapy:
action: "snap_pre"
test_files: "tests/test_loopback.yml"
- name: "Collect Post Snapshot"
jsnapy:
action: "snap_post"
test_files: "tests/test_loopback.yml"
- name: "Check after Pre and Post Snapshots"
jsnapy:
action: "check"
test_files: "tests/test_loopback.yml"
register: test3
- name: Verify all JSNAPy tests passed
assert:
that:
- "test3.|succeeded"
- "test3.passPercentage == 100"
- name: Print the full test response
debug:
var: test3
Return Values¶
name | description | returned | type | sample |
---|---|---|---|---|
action |
The JSNAPy action performed as specified by the action option.
|
success | str | |
changed |
Indicates if the device's state has changed. Since this module doesn't change the operational or configuration state of the device, the value is always set to
false . |
success | bool | |
failed |
Indicates if the task failed.
|
always | bool | |
msg |
A human-readable message indicating the result of the JSNAPy tests.
|
always | str |
Notes¶
Note
The NETCONF system service must be enabled on the target Junos device.
Status¶
This module is flagged as stableinterface which means that the maintainers for this module guarantee that no backward incompatible interface changes will be made.