salt.modules.mac_system

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

Returns:

A string value representing the boot architecture setting

Return type:

str

CLI Example:

salt '*' system.get_boot_arch
salt.modules.mac_system.get_computer_name()

Gets the computer name

Returns:

The computer name

Return type:

str

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.

Returns:

True if disable keyboard on lock is on, False if off

Return type:

bool

CLI Example:

salt '*' system.get_disable_keyboard_on_lock
salt.modules.mac_system.get_remote_events()

Displays whether remote apple events are on or off.

Returns:

True if remote apple events are on, False if off

Return type:

bool

CLI Example:

salt '*' system.get_remote_events
salt.modules.mac_system.get_remote_login()

Displays whether remote login (SSH) is on or off.

Returns:

True if remote login is on, False if off

Return type:

bool

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.

Returns:

A string value representing the number of seconds the system will delay restart after power loss

Return type:

str

CLI Example:

salt '*' system.get_restart_delay
salt.modules.mac_system.get_startup_disk()

Displays the current startup disk

Returns:

The current startup disk

Return type:

str

CLI Example:

salt '*' system.get_startup_disk
salt.modules.mac_system.get_subnet_name()

Gets the local subnet name

Returns:

The local subnet name

Return type:

str

CLI Example:

salt '*' system.get_subnet_name
salt.modules.mac_system.halt(at_time=None)

Halt a running system

Parameters:

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.

Returns:

A list of valid startup disks

Return type:

list

CLI Example:

salt '*' system.list_startup_disks
salt.modules.mac_system.restart(at_time=None)

Restart the system

Parameters:

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).

Parameters:

arch (str) --

A string representing the desired architecture. If no value is passed, default is assumed. Valid values include:

  • i386

  • x86_64

  • default

Returns:

True if successful, False if not

Return type:

bool

CLI Example:

salt '*' system.set_boot_arch i386
salt.modules.mac_system.set_computer_name(name)

Set the computer name

Parameters:

name (str) -- The new computer name

Returns:

True if successful, False if not

Return type:

bool

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.

Parameters:

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

Returns:

True if successful, False if not

Return type:

bool

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)

Parameters:

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

Returns:

True if successful, False if not

Return type:

bool

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.

Parameters:

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

Returns:

True if successful, False if not

Return type:

bool

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

Parameters:

seconds (int) -- The number of seconds. Must be a multiple of 30

Returns:

True if successful, False if not

Return type:

bool

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.

Parameters:

path (str) -- The valid startup disk path

Returns:

True if successful, False if not

Return type:

bool

CLI Example:

salt '*' system.set_startup_disk /System/Library/CoreServices
salt.modules.mac_system.set_subnet_name(name)

Set the local subnet name

Parameters:

name (str) -- The new local subnet name

Note

Spaces are changed to dashes. Other special characters are removed.

Returns:

True if successful, False if not

Return type:

bool

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

Parameters:

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.

Parameters:

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'