Can data type validation reference a variable for the possible enum values?

78 views
Skip to first unread message

David Karr

unread,
May 20, 2016, 2:23:56 PM5/20/16
to Puppet Users
Reading through "Learning Puppet 4", I noticed the ability to define parameter types with pretty specific constraints, like "Enum['foo','bar']", et cetera.

Is there any way for the list of possible enum values to be specified elsewhere and then referenced in the type specification?

Henrik Lindberg

unread,
May 22, 2016, 8:43:54 PM5/22/16
to puppet...@googlegroups.com
Yes, we added type aliases to the language:

type MyModule::MyEnum = Enum['foo', 'bar', 'fee', 'fum']

Which is stored in your module under <root>/types/myenum.pp and should
contain that type alias alone.

Check out R.I's blog post on this topic:
https://www.devco.net/archives/2016/03/18/puppet-4-type-aliases.php

- henrik

> --
> You received this message because you are subscribed to the Google
> Groups "Puppet Users" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to puppet-users...@googlegroups.com
> <mailto:puppet-users...@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/puppet-users/0ab28fec-64ae-4593-96b5-40644968fb10%40googlegroups.com
> <https://groups.google.com/d/msgid/puppet-users/0ab28fec-64ae-4593-96b5-40644968fb10%40googlegroups.com?utm_medium=email&utm_source=footer>.
> For more options, visit https://groups.google.com/d/optout.


--

Visit my Blog "Puppet on the Edge"
http://puppet-on-the-edge.blogspot.se/
Reply all
Reply to author
Forward
0 new messages