system

Initiate operational actions on the Junos system

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:

Module-specific Options

The following options may be specified for this module:

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 0
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.
vmhost
bool no False
  • yes
  • no
Whether or not this is a vmhost reboot.

Examples

---
- name: 'Explicit host argument'
  hosts: junos
  connection: local
  gather_facts: no
  collections:
    - juniper.device

  tasks:
    - name: Reboot all REs of the device
      system:
        action: "reboot"

    - name: Power off the other RE of the device.
      system:
        action: "shutdown"
        othe_re: True

    - name: Reboot this RE at 8pm today.
      system:
        action: "reboot"
        all_re: False
        at: "20:00"

    - name: Halt the system on 25 January 2018 at 4pm.
      system:
        action: "halt"
        at: "1801251600"

    - name: Reboot the system in 30 minutes.
      system:
        action: "reboot"
        in_min: 30

    - name: Reboot the system in 30 minutes.
      system:
        action: "reboot"
        at: "+30m"

    - name: Zeroize the local RE only.
      system:
        action: "zeroize"
        all_re: False

    - name: Zeroize all REs and overwrite medea.
      system:
        action: "zeroize"
        media: True

Return Values

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.