Data in Modules: Fail on unsupported OS

61 views
Skip to first unread message

plapp...@gmail.com

unread,
Aug 22, 2017, 7:34:12 AM8/22/17
to Puppet Users
Good morning :)

I'm currently writing a puppet module for the OpenBSD specific implementation of SNMPd, and was wondering if there is any elegant way  for the module to fail on unsupported operating systems?

With the params.pp-pattern, you can fail as the default of the OS-specific configuration; but how would I do this with the data comes via Hiera from the module itself (https://docs.puppet.com/puppet/4.10/hiera_migrate_modules.html#module-data-with-yaml-data-files)? 

Of course I can simply leave the common.yaml empty and the module will fail with missing variables, but I'd rather have a helpful error message about an unsupported OS (which will be less confusing, should this module be used by someone else but me).




Kind regards, 

Jake

Henrik Lindberg

unread,
Aug 22, 2017, 11:25:40 AM8/22/17
to puppet...@googlegroups.com
How about setting a value that represents a "poison pill" as the default
(for example "not supported"). Then for all supported the value would be
something other than the "poison pill". You then check if you got the
"poison" and then error with a descriptive error message.


- henrik
--

Visit my Blog "Puppet on the Edge"
http://puppet-on-the-edge.blogspot.se/

Michael Watters

unread,
Aug 25, 2017, 4:40:30 PM8/25/17
to Puppet Users
I usually do this within the manifest itself.  For example:

if $facts['osfamily']!='RedHat'{fail("$operatingsystem is not supported")}


Reply all
Reply to author
Forward
0 new messages