junos_install_config - Load a configuration file or snippet onto a device running Junos OS.

Author:Jeremy Schulman, Juniper Networks

Synopsis

New in version 1.0.0.

Load a complete Junos OS configuration (overwrite) or merge a configuration snippet onto a device running Junos OS and commit it. The default behavior is to perform a load merge operation (overwrite=’no’). This module performs an atomic lock/edit/unlock. If the process fails at any step, then all configuration changes are discarded. You can load the configuration using either NETCONF or the CONSOLE port. Specify the console option to use the CONSOLE port. You provide the configuration data in a file. Supported formats when using NETCONF include ASCII text, Junos XML elements, and Junos OS set commands. Configurations performed through the console must only use ASCII text formatting.

Options

parameter required default choices comments
check_commit_wait no None
  • 1 - 4
Set to number of seconds to wait between check and commit.
comment no None
    Provide a comment to the commit of the configuration
    confirm no None
      Provide a confirm in minutes to the commit of the configuration
      console no None
        Port configuration, per the netconify utility
        diffs_file no None
          Path to the file where any diffs will be written
          file yes
            Path to the file containing the Junos OS configuration data. If the file has a *.conf extension, the content is treated as text format. If the file has a *.xml extension, the content is treated as XML format. If the file has a *.set extension, the content is treated as Junos OS set commands.
            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.
                  overwrite no
                  • true
                  • false
                  • yes
                  • no
                  Specify whether the configuration file completely replaces the existing configuration.
                  passwd no assumes ssh-key active
                    Login password
                    port no 830
                      port number to use when connecting to the device
                      replace no
                      • true
                      • false
                      • yes
                      • no
                      Specify whether the configuration file uses "replace:" statements. (NETCONF only) NOT compatible with set format
                      savedir no None
                        Path to the local server directory where device facts and inventory files will be stored. This option is used only with the console option. Refer to the netconify utility for details.
                        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
                            Extend the NETCONF RPC timeout beyond the default value of 30 seconds. Set this value to accommodate configuration changes (commits) that might take longer than the default timeout interval.
                            update no
                            • true
                            • false
                            • yes
                            • no
                            If set to ``True`` Compare a complete loaded configuration against the candidate configuration. For each hierarchy level or configuration object that is different in the two configurations, the version in the loaded configuration replaces the version in the candidate configuration. When the configuration is later committed, only system processes that are affected by the changed configuration elements parse the new configuration. This action is supported from PyEZ 2.1
                            user no $USER
                              Login username

                              Note

                              Requires junos-eznc >= 1.2.2

                              Note

                              Requires junos-netconify >= 1.0.1, when using the console option

                              Examples


                              # load merge a change to the Junos OS configuration using NETCONF
                              
                              - junos_install_config:
                                  host={{ inventory_hostname }}
                                  file=banner.conf
                              
                              # load overwrite a new Junos OS configuration using the CONSOLE port
                              
                              - junos_install_config:
                                  host={{ inventory_hostname }}
                                  console="--telnet={{TERMSERV}},{{TERMSERV_PORT}}"
                                  file=default_new_switch.conf
                                  overwrite=yes
                              
                              # load merge a change to the Junos OS configuration using NETCONF and supplying a commit log message
                              - junos_install_config:
                                  host={{ inventory_hostname }}
                                  file=banner.conf
                                  comment="configured by ansible"
                              
                              # load replace a change to the Junos OS configuration using NETCONF
                              - junos_install_config:
                                  host={{ inventory_hostname }}
                                  file=snmp.conf
                                  replace=yes
                              
                              # Install/load config using console server connection using PyEZ >= 2.0
                              
                              - junos_install_config:
                                  host={{ inventory_hostname }}
                                  port=7016
                                  mode='telnet'
                                  file=default_new_switch.conf