Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BREAKING: refactor hiera data lookup #76

Merged
merged 1 commit into from Sep 12, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
22 changes: 22 additions & 0 deletions README.md
Expand Up @@ -111,6 +111,28 @@ autofs::mounts:
order: 01
```

If you need to merge the `autofs::mounts` key from multiple files or hiera lookups, be sure to add the `lookup_options`
key and set the merge behavior for `autofs::mounts` to `merge: hash`

```yaml
lookup_options:
autofs::mounts:
merge: hash
autofs::mounts:
home:
mount: '/home'
mapfile: '/etc/auto.home'
mapcontents:
- '* -user,rw,soft,intr,rsize=32768,wsize=32768,tcp,nfsvers=3,noacl server.example.com:/path/to/home/shares'
options: '--timeout=120'
order: 01
```

For more information about merge behavior see the doc for:

* [Lookup docs](https://docs.puppet.com/puppet/4.7/lookup_quick.html#puppet-lookup:-quick-reference-for-hiera-users)
* [Hiera 5 docs](https://docs.puppet.com/puppet/5.1/hiera_merging.html) if using Puppet >= 4.9

##### Direct Map `/-` arugment

The autofs module also supports the use of the built in autofs `/-` argument used with Direct Maps.
Expand Down
15 changes: 7 additions & 8 deletions manifests/init.pp
Expand Up @@ -74,8 +74,8 @@
# on boot.
#
class autofs (
Optional[Hash] $mounts = undef,
Optional[Hash] $maps = undef,
Hash[String, Hash] $mounts = {},
Hash[String, Hash] $maps = {},
String $package_ensure = 'installed',
Enum[ 'stopped', 'running' ] $service_ensure = 'running',
Boolean $service_enable = true,
Expand All @@ -85,12 +85,11 @@
contain '::autofs::service'
}

if $mounts {
$data = hiera_hash('autofs::mounts', $mounts)
create_resources('autofs::mount', $data)
$mounts.each |String $mount, Hash $attributes| {
autofs::mount { $mount: * => $attributes }
}
if $maps {
$_datamaps = hiera_hash('autofs::maps', $maps)
create_resources('autofs::map',$_datamaps)

$maps.each |String $map, Hash $attributes| {
autofs::map { $map: * => $attributes }
}
}
2 changes: 1 addition & 1 deletion spec/classes/autofs_spec.rb
Expand Up @@ -102,7 +102,7 @@
let(:params) { { mounts: mounts } }

it 'is expected to fail' do
is_expected.to compile.and_raise_error(%r{parameter 'mounts' expects a value of type Undef or Hash})
is_expected.to compile.and_raise_error(%r{parameter 'mounts' expects a Hash value})
end
end
end