.. _juniper_junos_system: juniper_junos_system ++++++++++++++++++++ Initiate operational actions on the Junos system .. versionadded:: 2.0.0 .. contents:: :local: :depth: 2 Synopsis -------- * Initiate an operational action (shutdown, reboot, halt or zeroize) on a Junos system. The particular action to execute is defined by the mandatory *action* option. Requirements ------------ The following software packages must be installed on hosts that execute this module: * `junos-eznc `_ >= 2.1.7 * Python >= 2.7 .. _module-specific-options-label: Module-specific Options ----------------------- The following options may be specified for this module: .. raw:: html
parameter type required default choices comments
action
str yes none
  • shutdown
  • halt
  • reboot
  • zeroize
  • off
  • power-off
  • power_off
The action performed by the module.
The following actions are supported:
shutdown - Power off the Junos devices. The values off, power-off, and power_off are aliases for this value. This is the equivalent of the request system power-off CLI command.
halt - Stop the Junos OS running on the RE, but do not power off the system. Once the system is halted, it will reboot if a keystroke is entered on the console. This is the equivalent of the request system halt CLI command.
reboot - Reboot the system. This is the equivalent of the request system reboot CLI command.
zeroize - Restore the system (configuration, log files, etc.) to a factory default state. This is the equivalent of the request system zeroize CLI command.
all_re
bool no True
  • yes
  • no
If the system has multiple Routing Engines and this option is true, then the action is performed on all REs in the system. If the system does not have multiple Routing Engines, then this option has no effect.
This option applies to all action values.
The all_re option is mutually exclusive with the other_re option.
at
str no none
The time at which to shutdown, halt, or reboot the system.
The value may be specified in one of the following ways:
now - The action takes effect immediately.
+minutes — The action takes effect in minutes minutes from now.
yymmddhhmm — The action takes effect at yymmddhhmm absolute time, specified as year, month, day, hour, and minute.
hh:mm — The action takes effect at hh:mm absolute time on the current day, specified in 24-hour time.
The at option can not be used when the action option has a value of zeroize. The at option is mutually exclusive with the in_min option.
in_min
int no none
Specify a delay, in minutes, before the shutdown, halt, or reboot.
The in_min option can not be used when the action option has a value of zeroize. The in_min option is mutually exclusive with the at option.
media
bool no False
  • yes
  • no
Overwrite media when performing the zeroize operation. This option is only valid when the action option has a value of zeroize.
other_re
bool no False
  • yes
  • no
If the system has dual Routing Engines and this option is true, then the action is performed on the other REs in the system. If the system does not have dual Routing Engines, then this option has no effect.
The other_re option can not be used when the action option has a value of zeroize.
The other_re option is mutually exclusive with the all_re option.

Common Connection-related Options --------------------------------- In addition to the :ref:`module-specific-options-label`, the following connection-related options are also supported by this module: .. raw:: html
parameter type required default choices comments
attempts
int no 10
The number of times to try connecting and logging in to the Junos device. This option is only applicable when using mode = 'telnet' or mode = 'serial'. Mutually exclusive with the console option.
baud
int no 9600
The serial baud rate, in bits per second, used to connect to the Junos device. This option is only applicable when using mode = 'serial'. Mutually exclusive with the console option.
console
str no none
An alternate method of specifying a NETCONF over serial console connection to the Junos device using Telnet to a console server. The value of this option must be a string in the format --telnet <console_hostname>,<console_port_number>. This option is deprecated. It is present only for backwards compatibility. The string value of this option is exactly equivalent to specifying host with a value of <console_hostname>, mode with a value of telnet, and port with a value of <console_port_number>. Mutually exclusive with the mode, port, baud, and attempts options.
host
str yes {{ inventory_hostname }}
The hostname or IP address of the Junos device to which the connection should be established. This is normally the Junos device itself, but is the hostname or IP address of a console server when connecting to the console of the device by setting the mode option to the value telnet. This option is required, but does not have to be specified explicitly by the user because it defaults to {{ inventory_hostname }}.

aliases: hostname, ip
mode
str no none
  • none
  • telnet
  • serial
The PyEZ mode used to establish a NETCONF connection to the Junos device. A value of none uses the default NETCONF over SSH mode. Depending on the values of the host and port options, a value of telnet results in either a direct NETCONF over Telnet connection to the Junos device, or a NETCONF over serial console connection to the Junos device using Telnet to a console server. A value of serial results in a NETCONF over serial console connection to the Junos device. Mutually exclusive with the console option.
passwd
str no The first defined value from the following list 1) The ANSIBLE_NET_PASSWORD environment variable. (used by Ansible Tower) 2) The value specified using the -k or --ask-pass command line arguments to the ansible or ansible-playbook command. 3) none (An empty password/passphrase)
The password, or ssh key's passphrase, used to authenticate with the Junos device. If this option is not specified, authentication is attempted using an empty password, or ssh key passphrase.

aliases: password
port
int or str no 830 if mode = none, 23 if mode = 'telnet', '/dev/ttyUSB0' if (mode = 'serial')
The TCP port number or serial device port used to establish the connection. Mutually exclusive with the console option.
provider
dict no
An alternative syntax for specifying the connection options. Rather than specifying each connection-related top-level option, the connection-related options may be specified as a dictionary of suboptions to the provider option. All connection-related options must either be specified as top-level options or as suboptions of the provider option. You can not combine the two methods of specifying connection-related options.
Dictionary object provider
parameter type required default choices comments
baud
int no 9600
The serial baud rate, in bits per second, used to connect to the Junos device. This option is only applicable when using mode = 'serial'. Mutually exclusive with the console option.
attempts
int no 10
The number of times to try connecting and logging in to the Junos device. This option is only applicable when using mode = 'telnet' or mode = 'serial'. Mutually exclusive with the console option.
console
str no none
An alternate method of specifying a NETCONF over serial console connection to the Junos device using Telnet to a console server. The value of this option must be a string in the format --telnet <console_hostname>,<console_port_number>. This option is deprecated. It is present only for backwards compatibility. The string value of this option is exactly equivalent to specifying host with a value of <console_hostname>, mode with a value of telnet, and port with a value of <console_port_number>. Mutually exclusive with the mode, port, baud, and attempts options.
passwd
str no The first defined value from the following list 1) The ANSIBLE_NET_PASSWORD environment variable. (used by Ansible Tower) 2) The value specified using the -k or --ask-pass command line arguments to the ansible or ansible-playbook command. 3) none (An empty password/passphrase)
The password, or ssh key's passphrase, used to authenticate with the Junos device. If this option is not specified, authentication is attempted using an empty password, or ssh key passphrase.
ssh_config
path no
The path to the SSH client configuration file. If this option is not specified, then the PyEZ Device instance by default queries file ~/.ssh/config.
host
str yes {{ inventory_hostname }}
The hostname or IP address of the Junos device to which the connection should be established. This is normally the Junos device itself, but is the hostname or IP address of a console server when connecting to the console of the device by setting the mode option to the value telnet. This option is required, but does not have to be specified explicitly by the user because it defaults to {{ inventory_hostname }}.
mode
str no none
  • none
  • telnet
  • serial
The PyEZ mode used to establish a NETCONF connection to the Junos device. A value of none uses the default NETCONF over SSH mode. Depending on the values of the host and port options, a value of telnet results in either a direct NETCONF over Telnet connection to the Junos device, or a NETCONF over serial console connection to the Junos device using Telnet to a console server. A value of serial results in a NETCONF over serial console connection to the Junos device. Mutually exclusive with the console option.
timeout
int no 30
The maximum number of seconds to wait for RPC responses from the Junos device. This option does NOT control the initial connection timeout value.
ssh_private_key_file
path no The first defined value from the following list 1) The ANSIBLE_NET_SSH_KEYFILE environment variable. (used by Ansible Tower) 2) The value specified using the --private-key or --key-file command line arguments to the ansible or ansible-playbook command. 3) none (the file specified in the user's SSH configuration, or the operating-system-specific default)
The path to the SSH private key file used to authenticate with the Junos device. If this option is not specified, and no default value is found using the algorithm below, then the SSH private key file specified in the user's SSH configuration, or the operating-system-specific default is used.
port
int or str no 830 if mode = none, 23 if mode = 'telnet', '/dev/ttyUSB0' if (mode = 'serial')
The TCP port number or serial device port used to establish the connection. Mutually exclusive with the console option.
user
str yes The first defined value from the following list 1) The ANSIBLE_NET_USERNAME environment variable. (used by Ansible Tower) 2) The remote_user as defined by Ansible. Ansible sets this value via several methods including a) -u or --user command line arguments to the ansible or ansible-playbook command. b) ANSIBLE_REMOTE_USER environment variable. c) remote_user configuration setting. See the Ansible documentation for the precedence used to set the remote_user value. 3) The USER environment variable.
The username used to authenticate with the Junos device. This option is required, but does not have to be specified explicitly by the user due to the algorithm for determining the default value.
ssh_config
path no
The path to the SSH client configuration file. If this option is not specified, then the PyEZ Device instance by default queries file ~/.ssh/config.
ssh_private_key_file
path no The first defined value from the following list 1) The ANSIBLE_NET_SSH_KEYFILE environment variable. (used by Ansible Tower) 2) The value specified using the --private-key or --key-file command line arguments to the ansible or ansible-playbook command. 3) none (the file specified in the user's SSH configuration, or the operating-system-specific default)
The path to the SSH private key file used to authenticate with the Junos device. If this option is not specified, and no default value is found using the algorithm below, then the SSH private key file specified in the user's SSH configuration, or the operating-system-specific default is used.

aliases: ssh_keyfile
timeout
int no 30
The maximum number of seconds to wait for RPC responses from the Junos device. This option does NOT control the initial connection timeout value.
user
str yes The first defined value from the following list 1) The ANSIBLE_NET_USERNAME environment variable. (used by Ansible Tower) 2) The remote_user as defined by Ansible. Ansible sets this value via several methods including a) -u or --user command line arguments to the ansible or ansible-playbook command. b) ANSIBLE_REMOTE_USER environment variable. c) remote_user configuration setting. See the Ansible documentation for the precedence used to set the remote_user value. 3) The USER environment variable.
The username used to authenticate with the Junos device. This option is required, but does not have to be specified explicitly by the user due to the algorithm for determining the default value.

aliases: username

Common Logging-related Options ------------------------------ In addition to the :ref:`module-specific-options-label`, the following logging-related options are also supported by this module: .. raw:: html
parameter type required default choices comments
level
str no WARNING
  • INFO
  • DEBUG
The level of information to be logged can be modified using this option
1) By default, messages at level WARNING or higher are logged.
2) If the -v or --verbose command-line options to the ansible-playbook command are specified, messages at level INFO or higher are logged.
3) If the -vv (or more verbose) command-line option to the ansible-playbook command is specified, or the ANSIBLE_DEBUG environment variable is set, then messages at level DEBUG or higher are logged.
4) If level is mentioned then messages at level level or more are logged.
logdir
path no none
The path to a directory, on the Ansible control machine, where debugging information for the particular task is logged.
If this option is specified, debugging information is logged to a file named {{ inventory_hostname }}.log in the directory specified by the logdir option.
The log file must be writeable. If the file already exists, it is appended. It is the users responsibility to delete/rotate log files.
The level of information logged in this file is controlled by Ansible's verbosity, debug options and level option in task
1) By default, messages at level WARNING or higher are logged.
2) If the -v or --verbose command-line options to the ansible-playbook command are specified, messages at level INFO or higher are logged.
3) If the -vv (or more verbose) command-line option to the ansible-playbook command is specified, or the ANSIBLE_DEBUG environment variable is set, then messages at level DEBUG or higher are logged.
4) If level is mentioned then messages at level level or more are logged.
The logfile and logdir options are mutually exclusive. The logdir option is recommended for all new playbooks.

aliases: log_dir
logfile
path no none
The path to a file, on the Ansible control machine, where debugging information for the particular task is logged.
The log file must be writeable. If the file already exists, it is appended. It is the users responsibility to delete/rotate log files.
The level of information logged in this file is controlled by Ansible's verbosity, debug options and level option in task
1) By default, messages at level WARNING or higher are logged.
2) If the -v or --verbose command-line options to the ansible-playbook command are specified, messages at level INFO or higher are logged.
3) If the -vv (or more verbose) command-line option to the ansible-playbook command is specified, or the ANSIBLE_DEBUG environment variable is set, then messages at level DEBUG or higher are logged.
4) If level is mentioned then messages at level level or more are logged.
When tasks are executed against more than one target host, one process is forked for each target host. (Up to the maximum specified by the forks configuration. See forks for details.) This means that the value of this option must be unique per target host. This is usually accomplished by including {{ inventory_hostname }} in the logfile value. It is the user's responsibility to ensure this value is unique per target host.
For this reason, this option is deprecated. It is maintained for backwards compatibility. Use the logdir option in new playbooks. The logfile and logdir options are mutually exclusive.

aliases: log_file

.. _juniper_junos_system-examples-label: Examples -------- :: --- - name: Examples of juniper_junos_system hosts: junos-all connection: local gather_facts: no roles: - Juniper.junos tasks: - name: Reboot all REs of the device juniper_junos_system: action: "reboot" - name: Power off the other RE of the device. juniper_junos_system: action: "shutdown" othe_re: True - name: Reboot this RE at 8pm today. juniper_junos_system: action: "reboot" all_re: False at: "20:00" - name: Halt the system on 25 January 2018 at 4pm. juniper_junos_system: action: "halt" at: "1801251600" - name: Reboot the system in 30 minutes. juniper_junos_system: action: "reboot" in_min: 30 - name: Reboot the system in 30 minutes. juniper_junos_system: action: "reboot" at: "+30m" - name: Zeroize the local RE only. juniper_junos_system: action: "zeroize" all_re: False - name: Zeroize all REs and overwrite medea. juniper_junos_system: action: "zeroize" media: True Return Values ------------- .. raw:: html
name description returned type sample
action
The value of the action option.
always str
all_re
The value of the all_re option.
always str
changed
Indicates if the device's state has changed. If the action is performed (or if it would have been performed when in check mode) then the value will be true. If there was an error before the action, then the value will be false.
always bool
failed
Indicates if the task failed.
always bool
media
The value of the media option.
always str
msg
A human-readable message indicating the result.
always str
other_re
The value of the other_re option.
always str


Notes ----- .. note:: - This module only **INITIATES** the action. It does **NOT** wait for the action to complete. - Some Junos devices are effected by a Junos defect which causes this Ansible module to hang indefinitely when connected to the Junos device via the console. This problem is not seen when connecting to the Junos device using the normal NETCONF over SSH transport connection. Therefore, it is recommended to use this module only with a NETCONF over SSH transport connection. However, this module does still permit connecting to Junos devices via the console port and this functionality may still be used for Junos devices running Junos versions less than 15.1. - The NETCONF system service must be enabled on the target Junos device. Author ~~~~~~ * Juniper Networks - Stacy Smith (@stacywsmith) 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.