I am making a module for a rails application. Problem is, every rails app has multiple .yml files aside from the standard database.yml. I wanted to handle configuration with Hiera dynamically.
The idea is to accept any configuration and populate it with the passed data.
I imagine my module would look like this.
### Given a configuration file for rails named app.yml which contains whatever dynamic content
# init.pp
class rails (
$configs = {},
) {
create_resources('rails::config', $configs, {})
}
define rails::config (
### how do i define this part to accept dynamic vars?
) {
}
### a sample hiera.yml would be like
rails::configs:
'app.yml':
'dynamic_key': 'dynamic_value'
'dynamic_key2':
- 'dynamic_value_as_hash1
- 'dynamic_value_as_hash2
How do you let a defined type accept a bunch of dynamic parameters?
Also, I was thinking that since these data are very specific to an application, maybe I could just create a separate hierarchy for the app so I can define defaults. That way, it doesn't have to be dynamic.
Sample hiera.yml would look like
---
:hierarchy:
- "%{::environment}/%{::fqdn}"
- "%{::environment}/%{::environment}"
- "%{::environment}/app/%{app}"
- global/common
:yaml:
:datadir: '/etc/puppetlabs/puppet/environments'
↧