ghoneycutt / puppet-module-types

Puppet module to manage default types through Hiera
Other
10 stars 21 forks source link

adding more parameters #38

Closed Phil-Friderici closed 8 years ago

Phil-Friderici commented 8 years ago

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 ?

Phil-Friderici commented 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.

ghoneycutt commented 8 years ago

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.

Phil-Friderici commented 8 years ago

@ghoneycutt I am wondering how this works as I can't find it in the code. Any hints ?

ghoneycutt commented 8 years ago

Not quite sure I follow your question. Above is how I use metaparameters in Hiera.

Phil-Friderici commented 8 years ago

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

ghoneycutt commented 8 years ago

Metaparameters are always available on all resources through Puppet itself.

Phil-Friderici commented 8 years ago

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'] ?

ghoneycutt commented 8 years ago

Hmmm, I think on both. Could try writing a spec test to inspect the catalog.

Phil-Friderici commented 8 years ago

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