Forge Home

mac_plist_value

Change values in property lists (plists) under Mac OS X

9,338 downloads

9,338 latest version

4.6 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.3.0 (latest)
released Apr 12th 2015
This version is compatible with:

Start using this module

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

Add this module to your Puppetfile:

mod 'jaredjennings-mac_plist_value', '0.3.0'
Learn more about managing modules with a Puppetfile

Add this module to your Bolt project:

bolt module add jaredjennings-mac_plist_value
Learn more about using this module with an existing project

Manually install this module globally with Puppet module tool:

puppet module install jaredjennings-mac_plist_value --version 0.3.0

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

jaredjennings/mac_plist_value — version 0.3.0 Apr 12th 2015

Property lists in Mac OS X

This is a Puppet module that provides resource types that manage property lists under Mac OS X. Some property lists are stored in files; some others are stored in the directory service. Both locations are supported.

Setting values in property lists in files

The file must exist, even if it is empty. You may need to use a file resource to make sure the file will exist. This is so that you can be sure of the ownership and permissions of a property list file that you may be creating.

Examples:

    mac_plist_value { 'meaningless unique name with no colons':
    file => '/path/to/settings.plist',
    key => ['key', 'key2'],
    value => 3,
    }
    mac_plist_value { '/path/to/settings.plist:key/key2':
    value => 3,
    }
    mac_plist_value { '/path/to/settings.plist:key/key2':
    ensure => absent,
    }
    mac_plist_value { '/path/to/settings.plist:key':
    value => { 'key2' => 3, },
    }
    mac_plist_value { '/path/to/a.plist:key/*/otherkey':
    value => 3,
    }
    mac_plist_value { 'meaningless unique name w/o colons':
    file => '/path/to/a.plist',
    key => ['key', '*', 'otherkey'],
    value => 3,
    }

If the property list file's name has a colon in it, you must use the syntax with the file parameter.

Setting values in MCX property lists

Examples:

    mac_mcx_plist_value { 'meaningless but unique name':
    record => '/Computers/host1.example.com',
    key => ['com.example.app', 'mount-controls', 'dvd'],
    mcx_domain => 'always',
    value => { 'zap-sound' => 'blat' },
    }
    mac_mcx_plist_value { "/Computers/host1.example.com:\
        com.example.app/mount-controls/dvd":
    value => 3,
    }
    mac_mcx_plist_value { 'meaningless unique 2':
    record => '/Computers/host1.example.com',
    key => ['com.example.app', 'mount-controls', 'dvd', 1],
    ensure => absent,
    }

Value types

When setting property list values, the type of the value must be known. Unlike a few other modules on the Forge which support the alteration of property lists, this one is so bold as to try to infer the type of the value you have given. So values of true and false are taken to be booleans; values comprised entirely of digits will likely end up as integers.

If you need a value in a property list to be an array with one item in it, you have to put an empty string after that item, like

    value => ['thing i wanted', '']

The empty string will be stripped off at the proper time.

Mac OS X version compatibility

Just like Gary Larizza's property_list_key, q.v., this module started out dealing with property lists using RubyCocoa, which was provided (at least) with Snow Leopard, then moved to using CFPropertyList, which is provided (at least) with Mavericks. Both means of property list editing still exist as separate providers for the resource types given here.