System module for sleeping, restarting, and shutting down the system on Mac OS X
New in version 2016.3.0.
Warning
Using this module will enable atrun
on the system if it is disabled.
salt.modules.mac_system.
get_boot_arch
()¶Get the kernel architecture setting from com.apple.Boot.plist
A string value representing the boot architecture setting
CLI Example:
salt '*' system.get_boot_arch
salt.modules.mac_system.
get_computer_name
()¶Gets the computer name
The computer name
CLI Example:
salt '*' system.get_computer_name
salt.modules.mac_system.
get_disable_keyboard_on_lock
()¶Get whether or not the keyboard should be disabled when the X Serve enclosure lock is engaged.
True if disable keyboard on lock is on, False if off
CLI Example:
..code-block:: bash
salt '*' system.get_disable_keyboard_on_lock
salt.modules.mac_system.
get_remote_events
()¶Displays whether remote apple events are on or off.
True if remote apple events are on, False if off
CLI Example:
salt '*' system.get_remote_events
salt.modules.mac_system.
get_remote_login
()¶Displays whether remote login (SSH) is on or off.
True if remote login is on, False if off
CLI Example:
salt '*' system.get_remote_login
salt.modules.mac_system.
get_restart_delay
()¶Get the number of seconds after which the computer will start up after a power failure.
A string value representing the number of seconds the system will delay restart after power loss
CLI Example:
salt '*' system.get_restart_delay
salt.modules.mac_system.
get_startup_disk
()¶Displays the current startup disk
The current startup disk
CLI Example:
salt '*' system.get_startup_disk
salt.modules.mac_system.
get_subnet_name
()¶Gets the local subnet name
The local subnet name
CLI Example:
salt '*' system.get_subnet_name
salt.modules.mac_system.
halt
(at_time=None)¶Halt a running system
at_time (str) --
Any valid at expression. For example, some valid at expressions could be:
noon
midnight
fri
9:00 AM
2:30 PM tomorrow
now + 10 minutes
Note
If you pass a time only, with no 'AM/PM' designation, you have to double quote the parameter on the command line. For example: '"14:00"'
CLI Example:
salt '*' system.halt
salt '*' system.halt 'now + 10 minutes'
salt.modules.mac_system.
list_startup_disks
()¶List all valid startup disks on the system.
A list of valid startup disks
CLI Example:
salt '*' system.list_startup_disks
salt.modules.mac_system.
restart
(at_time=None)¶Restart the system
at_time (str) --
Any valid at expression. For example, some valid at expressions could be:
noon
midnight
fri
9:00 AM
2:30 PM tomorrow
now + 10 minutes
Note
If you pass a time only, with no 'AM/PM' designation, you have to double quote the parameter on the command line. For example: '"14:00"'
CLI Example:
salt '*' system.restart
salt '*' system.restart '12:00 PM fri'
salt.modules.mac_system.
set_boot_arch
(arch='default')¶Set the kernel to boot in 32 or 64 bit mode on next boot.
Note
When this function fails with the error changes to kernel
architecture failed to save!
, then the boot arch is not updated.
This is either an Apple bug, not available on the test system, or a
result of system files being locked down in macOS (SIP Protection).
arch (str) --
A string representing the desired architecture. If no value is passed, default is assumed. Valid values include:
i386
x86_64
default
True if successful, False if not
CLI Example:
salt '*' system.set_boot_arch i386
salt.modules.mac_system.
set_computer_name
(name)¶Set the computer name
name (str) -- The new computer name
True if successful, False if not
CLI Example:
salt '*' system.set_computer_name "Mike's Mac"
salt.modules.mac_system.
set_disable_keyboard_on_lock
(enable)¶Get whether or not the keyboard should be disabled when the X Serve enclosure lock is engaged.
enable (bool) -- True to enable, False to disable. "On" and "Off" are also acceptable values. Additionally you can pass 1 and 0 to represent True and False respectively
True if successful, False if not
CLI Example:
salt '*' system.set_disable_keyboard_on_lock False
salt.modules.mac_system.
set_remote_events
(enable)¶Set whether the server responds to events sent by other computers (such as AppleScripts)
enable (bool) -- True to enable, False to disable. "On" and "Off" are also acceptable values. Additionally you can pass 1 and 0 to represent True and False respectively
True if successful, False if not
CLI Example:
salt '*' system.set_remote_events On
salt.modules.mac_system.
set_remote_login
(enable)¶Set the remote login (SSH) to either on or off.
enable (bool) -- True to enable, False to disable. "On" and "Off" are also acceptable values. Additionally you can pass 1 and 0 to represent True and False respectively
True if successful, False if not
CLI Example:
salt '*' system.set_remote_login True
salt.modules.mac_system.
set_restart_delay
(seconds)¶Set the number of seconds after which the computer will start up after a power failure.
Warning
This command fails with the following error:
Error, IOServiceOpen returned 0x10000003
The setting is not updated. This is an apple bug. It seems like it may only work on certain versions of Mac Server X. This article explains the issue in more detail, though it is quite old.
http://lists.apple.com/archives/macos-x-server/2006/Jul/msg00967.html
seconds (int) -- The number of seconds. Must be a multiple of 30
True if successful, False if not
CLI Example:
salt '*' system.set_restart_delay 180
salt.modules.mac_system.
set_startup_disk
(path)¶Set the current startup disk to the indicated path. Use
system.list_startup_disks
to find valid startup disks on the system.
path (str) -- The valid startup disk path
True if successful, False if not
CLI Example:
salt '*' system.set_startup_disk /System/Library/CoreServices
salt.modules.mac_system.
set_subnet_name
(name)¶Set the local subnet name
name (str) -- The new local subnet name
Note
Spaces are changed to dashes. Other special characters are removed.
True if successful, False if not
CLI Example:
The following will be set as 'Mikes-Mac'
salt '*' system.set_subnet_name "Mike's Mac"
salt.modules.mac_system.
shutdown
(at_time=None)¶Shutdown the system
at_time (str) --
Any valid at expression. For example, some valid at expressions could be:
noon
midnight
fri
9:00 AM
2:30 PM tomorrow
now + 10 minutes
Note
If you pass a time only, with no 'AM/PM' designation, you have to double quote the parameter on the command line. For example: '"14:00"'
CLI Example:
salt '*' system.shutdown
salt '*' system.shutdown 'now + 1 hour'
salt.modules.mac_system.
sleep
(at_time=None)¶Sleep the system. If a user is active on the system it will likely fail to sleep.
at_time (str) --
Any valid at expression. For example, some valid at expressions could be:
noon
midnight
fri
9:00 AM
2:30 PM tomorrow
now + 10 minutes
Note
If you pass a time only, with no 'AM/PM' designation, you have to double quote the parameter on the command line. For example: '"14:00"'
CLI Example:
salt '*' system.sleep
salt '*' system.sleep '10:00 PM'