puppetlabs / best-practices

Best practice docs created by the Puppet Customer Success team
Apache License 2.0
119 stars 47 forks source link

Default value in class #24

Closed reidmv closed 5 years ago

reidmv commented 5 years ago

Proposal for addressing strings docs issue

See proposed change for details.

If we value puppet strings output for generating documentation, we need to address a shortcoming it has with regards to data-in-modules. This commit proposes a best practice that assumes the tooling as it exists today.

Note that as an alternative, the tension/shortcoming could be resolved by an improvement to puppet-strings. Discuss!

abuxton commented 5 years ago

line #24 is now incorrect cos plans use .pp too (just a nitpick) but other than that what you’ve written follows what Gary last preached with the post on data and hiera abstraction. static defaults should be code not data, overrides for platforms (os etc) should be data so the module can be reused etc etc (https://puppet.com/blog/hiera-data-and-puppet-code-your-path-right-data-decisions)

Sharpie commented 5 years ago

I think like 24 is still fine because it explicitly says:

*.pp files containing classes or defined types

As far as I know, the plans/ directory contains plan foo(...) {...} definitions and the functions/ directory contains function bar(...) {...} definitions, but neither can contain class blah(...) {...} or define blam(...) {...}.

trevor-vaughan commented 5 years ago

This seems relevant to the discussion from the puppet strings point of view: https://tickets.puppetlabs.com/browse/PDOC-171

Personally, I really like having values in my documentation and in the Puppet Console. A field that just says "open the code" doesn't seem all that useful in general.