macdefaults

contributions requested
pdk
Manages macOS preferences using defaults.

2,084 downloads

1,975 latest version

5.0 quality score

Support the Puppet Community by contributing to this module

You are welcome to contribute to this module by suggesting new features, currency updates, or fixes. Every contribution is valuable to help ensure that the module remains compatible with the latest Puppet versions and continues to meet community needs. Complete the following steps:

  1. Review the module’s contribution guidelines and any licenses. Ensure that your planned contribution aligns with the author’s standards and any legal requirements.
  2. Fork the repository on GitHub, make changes on a branch of your fork, and submit a pull request. The pull request must clearly document your proposed change.

For questions about updating the module, contact the module’s author.

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
  • Darwin

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.