Skip to content

Commit

Permalink
Add $config parameter to simplify usage from hiera
Browse files Browse the repository at this point in the history
Based on a patch provided by Benedikt Trefzer (#2)
  • Loading branch information
oxc committed Mar 3, 2019
1 parent 48e2078 commit 4fa3efb
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 10 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## [Unreleased]
### Added
- $rspamd::config parameter to simplify usage from hiera out of the box ([#2]).

## Release [1.0.2] - 2018-01-28
### Summary
Expand Down Expand Up @@ -59,3 +61,4 @@ Initial development, was not used or tested on a production system
[1.0.0]: https://github.com/oxc/puppet-rspamd/compare/v0.2.1...v1.0.0
[0.2.1]: https://github.com/oxc/puppet-rspamd/compare/v0.2.0...v0.2.1
[0.2.0]: https://github.com/oxc/puppet-rspamd/compare/1980687...v0.2.0
[#2]: https://github.com/oxc/puppet-rspamd/pull/2
28 changes: 18 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,18 +74,11 @@ statfile {
}
```


The provided `rspamd::create_config_resources` and `rspamd::create_config_file_resources`
functions allow for a much more convenient usage, especially with values stored in hiera:

```puppet
class profile::rspamd {
rspamd::create_config_file_resources(hiera_hash("${title}::config", {}))
}
```
Using the rspamd `$config` parameter, values for multiple config files can
easily be provided from hiera:

```yaml
profile::rspamd::config:
rspamd::config:
classifier-bayes:
backend: redis
servers: "127.0.0.1:6379"
Expand All @@ -96,6 +89,21 @@ profile::rspamd::config:
spam: true
```

This uses the provided `rspamd::create_config_resources` and `rspamd::create_config_file_resources`
functions, which can be used in custom profiles for extended use cases:

```puppet
class profile::mail::rspamd (
Hash $config,
Hash $override_config,
) {
class { 'rspamd': }
rspamd::create_config_file_resources($config)
rspamd::create_config_file_resources($override_config, { mode => 'override' })
}
```


## Reference

Expand Down
1 change: 1 addition & 0 deletions data/common.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ rspamd::package_name: 'rspamd'
rspamd::purge_unmanaged: true
rspamd::repo_baseurl: ~
rspamd::service_manage: true
rspamd::config: {}
2 changes: 2 additions & 0 deletions manifests/configuration.pp
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,6 @@
purge => true,
}
}

rspamd::create_config_file_resources($rspamd::config)
}
1 change: 1 addition & 0 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
Boolean $purge_unmanaged,
Optional[String] $repo_baseurl,
Boolean $service_manage,
Hash $config,
) {
contain rspamd::repo
contain rspamd::install
Expand Down

0 comments on commit 4fa3efb

Please sign in to comment.