Support for reboot, shutdown, etc on POSIX-like systems.
Note
If you have configured a wrapper such as molly-guard
to
intercept interactive shutdown commands, be aware that calling
system.halt
, system.poweroff
, system.reboot
, and
system.shutdown
with salt-call
will hang indefinitely
while the wrapper script waits for user input. Calling them with
salt
will work as expected.
Get PRETTY_HOSTNAME value stored in /etc/machine-info If this file doesn't exist or the variable doesn't exist return False.
Value of PRETTY_HOSTNAME if this does not exist False.
CLI Example:
salt '*' system.get_computer_desc
Get hostname.
CLI Example:
salt '*' network.get_hostname
Determine if at any time during the current boot session the salt minion witnessed an event indicating that a reboot is required.
True
if the a reboot request was witnessed, False
otherwise
CLI Example:
salt '*' system.get_reboot_required_witnessed
Get the system date
utc_offset (str) -- The utc offset in 4 digit (+0600) format with an optional sign (+/-). Will default to None which will use the local timezone. To set the time based off of UTC use "'+0000'". Note: if being passed through the command line will need to be quoted twice to allow negative offsets.
Returns the system date.
CLI Example:
salt '*' system.get_system_date
Get the system date/time.
utc_offset (str) -- The utc offset in 4 digit (+0600) format with an optional sign (+/-). Will default to None which will use the local timezone. To set the time based off of UTC use "'+0000'". Note: if being passed through the command line will need to be quoted twice to allow negative offsets.
Returns the system time in YYYY-MM-DD hh:mm:ss format.
CLI Example:
salt '*' system.get_system_date_time "'-0500'"
Get the system time.
utc_offset (str) -- The utc offset in 4 digit (+0600) format with an optional sign (+/-). Will default to None which will use the local timezone. To set the time based off of UTC use "'+0000'". Note: if being passed through the command line will need to be quoted twice to allow negative offsets.
Returns the system time in HH:MM:SS AM/PM format.
CLI Example:
salt '*' system.get_system_time
Halt a running system
CLI Example:
salt '*' system.halt
Returns True if the system has a hardware clock capable of being set from software.
CLI Example:
salt '*' system.has_settable_hwclock
Change the system runlevel on sysV compatible systems
CLI Example:
salt '*' system.init 3
Poweroff a running system
CLI Example:
salt '*' system.poweroff
Reboot the system
The wait time in minutes before the system will be rebooted.
CLI Example:
salt '*' system.reboot
Set PRETTY_HOSTNAME value stored in /etc/machine-info This will create the file if it does not exist. If it is unable to create or modify this file returns False.
desc (str) -- The computer description
False on failure. True if successful.
CLI Example:
salt '*' system.set_computer_desc "Michael's laptop"
Modify hostname.
CLI Example:
salt '*' system.set_computer_name master.saltstack.com
This function is used to remember that an event indicating that a reboot is required was witnessed. This function writes to a temporary filesystem so the event gets cleared upon reboot.
True
if successful, otherwise False
salt '*' system.set_reboot_required_witnessed
Set the system date. Use <mm-dd-yy> format for the date.
newdate (str) --
The date to set. Can be any of the following formats:
YYYY-MM-DD
MM-DD-YYYY
MM-DD-YY
MM/DD/YYYY
MM/DD/YY
YYYY/MM/DD
CLI Example:
salt '*' system.set_system_date '03-28-13'
Set the system date and time. Each argument is an element of the date, but not required. If an element is not passed, the current system value for that element will be used. For example, if you don't pass the year, the current system year will be used. (Used by set_system_date and set_system_time)
Updates hardware clock, if present, in addition to software (kernel) clock.
years (int) -- Years digit, ie: 2015
months (int) -- Months digit: 1 - 12
days (int) -- Days digit: 1 - 31
hours (int) -- Hours digit: 0 - 23
minutes (int) -- Minutes digit: 0 - 59
seconds (int) -- Seconds digit: 0 - 59
utc_offset (str) -- The utc offset in 4 digit (+0600) format with an optional sign (+/-). Will default to None which will use the local timezone. To set the time based off of UTC use "'+0000'". Note: if being passed through the command line will need to be quoted twice to allow negative offsets.
True if successful. Otherwise False.
CLI Example:
salt '*' system.set_system_date_time 2015 5 12 11 37 53 "'-0500'"
Set the system time.
newtime (str) --
The time to set. Can be any of the following formats. - HH:MM:SS AM/PM - HH:MM AM/PM - HH:MM:SS (24 hour) - HH:MM (24 hour)
Note that the salt command line parser parses the date/time before we obtain the argument (preventing us from doing utc) Therefore the argument must be passed in as a string. Meaning you may have to quote the text twice from the command line.
utc_offset (str) -- The utc offset in 4 digit (+0600) format with an optional sign (+/-). Will default to None which will use the local timezone. To set the time based off of UTC use "'+0000'". Note: if being passed through the command line will need to be quoted twice to allow negative offsets.
Returns True if successful. Otherwise False.
CLI Example:
salt '*' system.set_system_time "'11:20'"
Shutdown a running system
The wait time in minutes before the system will be shutdown.
CLI Example:
salt '*' system.shutdown 5