junos_cli - Execute CLI on device and save the output locally

Author:Damien Garros, Juniper Networks

Synopsis

New in version 1.2.0.

Execute CLI on device and save the output locally on a file

Options

parameter required default choices comments
cli yes
    CLI command to execute on the host
    dest no None
      Path to the local server directory where cli output will be saved.
      format no text
      • text
      • xml
      text - Cli output saved in text formatxml - Cli output saved as XML
      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**
                  timeout no 0
                    Set the NETCONF RPC timeout. Set this value to accommodate Cli commands that might take longer than the default timeout interval. Setting to 0 will use the PyEZ default (30 seconds).
                    user no $USER
                      Login username

                      Note

                      Requires junos-eznc >= 1.2.2

                      Examples


                      - junos_cli:
                         host: "{{ inventory_hostname }}"
                         cli: "show chassis hardware"
                         logfile: cli.log
                         dest: "{{ inventory_hostname }}.xml"
                         format: xml
                      
                      # Run cli over console server connection using PyEZ >= 2.0
                      - junos_cli:
                          cli="show chassis hardware"
                          host={{ inventory_hostname }}
                          port=7001
                          mode='telnet'
                          dest="{{ inventory_hostname }}.xml"
                          format='xml'