Closed Phil-Friderici closed 8 years ago
Started working on the metaparameters here: https://github.com/Phil-Friderici/puppet-module-types/pull/1
Too bad it fails while validating the manifests
before is a metaparam; this value will inherit to all contained resources in the types::cron definition notify is a metaparam; this value will inherit to all contained resources in the types::cron definition require is a metaparam; this value will inherit to all contained resources in the types::cron definition subscribe is a metaparam; this value will inherit to all contained resources in the types::cron definition
https://travis-ci.org/Phil-Friderici/puppet-module-types/jobs/136619213
Guessing it would be ok to inherit the metaparam to all contained resources as there is only one.
Metaparameters already work. So you can add before/require/notify/subscribe/tag in Hiera.
types::files:
'/tmp/foo':
ensure: 'file'
notify: 'Service[x]'
The reasoning behind just using the path is that you generally are not referring to these resources from your manifests. If you would like to add support for using path
and resource names, I'm OK with that.
@ghoneycutt I am wondering how this works as I can't find it in the code. Any hints ?
Not quite sure I follow your question. Above is how I use metaparameters in Hiera.
Yes, I have tested it successfully, but I don't understand how the metaparameters get to the resource on it's way through the code.
In the main class they will be just passed with the hash. But there is no code in the receiving file define to handle them: https://github.com/ghoneycutt/puppet-module-types/blob/master/manifests/file.pp#L36-L61
Metaparameters are always available on all resources through Puppet itself.
Taking your example again:
types::files: '/tmp/foo': ensure: 'file' notify: 'Service[x]'
So the metaparameter is bound to the Types__Files['/tmp/foo']
resource not on the resulting File['/tmp/foo']
?
Hmmm, I think on both. Could try writing a spec test to inspect the catalog.
Good idea, I have created some spec tests [1].
The test results show that all metaparameters will be added to Types__Files['/tmp/foo']
but none to File[/tmp/foo]
if you use a hash for $types::files.
If you pass them on $type::file, only the tag metaparam will be added to File[/tmp/foo]
That's good enough to work with :)
[1] https://github.com/Phil-Friderici/puppet-module-types/pull/2 https://travis-ci.org/Phil-Friderici/puppet-module-types/builds/137457658
I would like to add support for the relationship and ordering metaparameters
before / require / notify / subscribe
to all applicable types. This would help fine tweaking a lot.Also I would like to add support for the parameter 'path' to the file resource. That would enable us to use resource names other than full paths only.
Does that sounds good or stupid ?