junos_jsnapy

Author:Roslan Zaki & Damien Garros, Juniper Networks

Synopsis

New in version 1.4.0.

Execute JSNAPy test from Ansible. Attention, to not break Ansible behavior, this module only report “failed” if the module itself fails, not if a test fails. To check the test results you need to subscribe to the result and assert the returned value. An experimental Callback_Plugin for junos_jsnapy is available to provide additional information about tests that failed. To enable it, you need to add “callback_whitelist = jsnapy” in your ansible configuration file.

Options

parameter required default choices comments
action no None
    Possible actions available - jsnapcheck - check - snap_pre - snap_post
    config_file no None
      The YAML configuration file for the JSNAPy tests
      dir no /etc/jsnapy/testfiles
        Path for the JSNAPy yaml testfiles/configuration file
        host yes
          Set to {{ inventory_hostname }}
          logfile no None
            Path on the local server where the progress status is logged for debugging purposes
            mode no None
              mode of console connection (telnet/serial). If mode is not provided SSH connection is used.
              passwd no assumes ssh-key active
                Login password
                port no 830
                  port number to use when connecting to the device
                  ssh_private_key_file no None
                    This can be used if you need to provide a private key rather than loading the key into the ssh-key-ring/environment. if your ssh-key requires a password, then you must provide it via **passwd**
                    test_files no None
                      Test files which need to executed
                      user no $USER
                        Login username

                        Note

                        Requires junos-eznc >= 1.2.2

                        Examples


                           - name: JUNOS Post Checklist
                             junos_jsnapy:
                               host: "{{ inventory_hostname}}"
                               passwd: "{{ tm1_password }}"
                               action: "snap_post"
                               config_file: "first_test.yml"
                               logfile: "migration_post.log"
                             register: test1
                        
                           - name: Check JSNAPy tests results
                             assert:
                             that:
                               - "test1.passPercentage == 100"
                        
                           - name: Debug jsnapy
                             debug: msg=test1
                        
                        ---------
                           - name: Test based on a test_file directly
                             junos_jsnapy:
                               host: "{{ junos_host }}"
                               port: "{{ netconf_port }}"
                               user: "{{ ansible_ssh_user }}"
                               passwd: "{{ ansible_ssh_pass }}"
                               test_files: tests/test_junos_interface.yaml
                               action: snapcheck
                             register: test1
                        
                           - name: Check JSNAPy tests results
                             assert:
                             that:
                               - "test1.passPercentage == 100"
                        ---------
                           - name: "Collect Pre Snapshot"
                            junos_jsnapy:
                              host: "{{ junos_host }}"
                              port: "{{ netconf_port }}"
                              user: "{{ ansible_ssh_user }}"
                              passwd: "{{ ansible_ssh_pass }}"
                              test_files: tests/test_loopback.yml
                              action: snap_pre
                            register: test_pre
                        
                        ---------
                          - name: "Collect Post Snapshot"
                            junos_jsnapy:
                              host: "{{ junos_host }}"
                              port: "{{ netconf_port }}"
                              user: "{{ ansible_ssh_user }}"
                              passwd: "{{ ansible_ssh_pass }}"
                              test_files: tests/test_loopback.yml
                              action: snap_post
                            register: test_post
                        
                        ---------
                          - name: "Check after PRE - POST check"
                            junos_jsnapy:
                              host: "{{ junos_host }}"
                              port: "{{ netconf_port }}"
                              user: "{{ ansible_ssh_user }}"
                              passwd: "{{ ansible_ssh_pass }}"
                              test_files: tests/test_loopback.yml
                              action: check
                            register: test_check
                        
                            - name: Check Results
                              assert:
                                that:
                                  - test_check|succeeded
                                  - test_check.passPercentage == 100