Skip to content

Commit a2d4688

Browse files
committed
Rubyhash
0 parents  commit a2d4688

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

README.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# puppet-mac_stdlib
2+
3+
This module contains functions that are useful in the administration of macOS.
4+
5+
## `plist`
6+
7+
This function accepts a hash and will convert it into a plist. This requires the [CFPropertyList](https://github.com/ckruse/CFPropertyList/) gem to be installed on your Puppet Server (`sudo puppetserver gem install cfpropertylist`).
8+
9+
### Example
10+
11+
``` puppet
12+
$plist = {
13+
'SomeKey' => 'Some Value',
14+
'Another Key' => 'Another Value'
15+
}
16+
17+
file {'/tmp/a.plist':
18+
content => plist($plist, binary),
19+
}
20+
```
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# ruby hash
2+
3+
require 'puppet/util/plist' if Puppet.features.cfpropertylist?
4+
5+
module Puppet::Parser::Functions
6+
newfunction(:plist, type: :rvalue) do |args|
7+
hash = args[0] || {}
8+
format = args[1] || :xml
9+
10+
return Puppet::Util::Plist.dump_plist(hash, format)
11+
end
12+
end

0 commit comments

Comments
 (0)