Forge Home

macdefaults

Manages macOS preferences using defaults.

2,002 downloads

1,913 latest version

5.0 quality score

We run a couple of automated
scans to help you access a
module's quality. Each module is
given a score based on how well
the author has formatted their
code and documentation and
modules are also checked for
malware using VirusTotal.

Please note, the information below
is for guidance only and neither of
these methods should be considered
an endorsement by Puppet.

Version information

  • 0.1.2 (latest)
  • 0.1.1
released Feb 18th 2020
This version is compatible with:
  • Puppet Enterprise 2019.8.x, 2019.7.x, 2019.5.x, 2019.4.x, 2019.3.x, 2019.2.x, 2019.1.x, 2019.0.x, 2018.1.x, 2017.3.x, 2017.2.x, 2016.4.x
  • Puppet >= 4.10.0 < 7.0.0

Start using this module

  • r10k or Code Manager
  • Bolt
  • Manual installation
  • Direct download

Add this module to your Puppetfile:

mod 'call-macdefaults', '0.1.2'
Learn more about managing modules with a Puppetfile

Add this module to your Bolt project:

bolt module add call-macdefaults
Learn more about using this module with an existing project

Manually install this module globally with Puppet module tool:

puppet module install call-macdefaults --version 0.1.2

Direct download is not typically how you would use a Puppet module to manage your infrastructure, but you may want to download the module in order to inspect the code.

Download

Documentation

call/macdefaults — version 0.1.2 Feb 18th 2020

macOS Defaults module for Puppet

This module defines a macdefaults type which can manage preferences on macOS/OS X.

The macdefaults type enables Puppet to manage any setting that is changed or set using defaults.

A macdefaults type obviates the need to include a large number of redundant exec statements to accomplish the same thing, for example:

exec {'Set default paper size to A4':
  command   => 'usr/bin/defaults write /Library/Preferences/com.apple.print.PrintingPrefs DefaultPaperID -string "iso-a4"',
  unless    => "/usr/bin/defaults read /Library/Preferences/com.apple.print.PrintingPrefs DefaultPaperID | grep iso-a4,
}

Usage

  • Add this module to your Puppet modules directory via r10k (recommended) or downloading and unzipping.
  • Make use of the code in any Puppet manifest or other module:
macdefaults { 'set-a4':
  domain => '/Library/Preferences/com.apple.print.PrintingPrefs',
  key    => 'DefaultPaperID',
  type   => 'string',
  value  => 'iso-a4'
}

Values

Possible values for type are:

  • string
  • data
  • int
  • float
  • bool
  • data
  • array
  • array-add
  • dict
  • dict-add

Notes

For values which can be managed via a configuration profile, it is reccomended to use the mac_profiles_handler

This module can be used for general property list key manipulation, just like defaults, but it is reccomended to use Gary Larizza's property_list_key provider instead.

I didn't write 90% of this, but I can't for the life of me remember where I found it. I'm putting it on here for posterity.

This has been updated to be used as macdefaults instead of mac-defaults to be compatible with Puppet 4.

To Do

  • Move the working parts to Ruby to better support dictionaries and arrays, as well as to remove the dependency on grep.