| Puppet Version: 6.15.0 Puppet Server Version: 6.11.1 OS Name/Version: CentOS7 Hi, We're upgrading to Puppet6 and we encountered an interesting situation we'd like to discuss with you. Please note that as explained below this is not a blocker for us but we believe it's worth discussing it to know what's the best path to take in terms of patching our code. We've got this in our code base:
class foo::bar ( |
Array[Variant[String, Regexp]] $my_param, |
...
|
Allowing us to use a single parameter to later on apply configuration depending on the type of the element of the collection:
$_directories = map($my_param) | Variant[String, Regexp] $_url | { |
{ |
provider => $_url ? { |
String => 'directory', |
Regexp => 'directorymatch', |
}, |
path => $_url ? { |
String => "${something}/${_url}", |
Regexp => $_url, |
}, |
... |
}
|
To finally inject data into that class using Hiera (YAML backend) like this:
foo::bar::my_param: |
- 'foo/' |
- 'bar/' |
- !ruby/regexp '/baz(|-cool)/'
|
This is handy, kind of tidy and working code in Puppet5. We're basically taking advantage of the existence of type system to map Puppet types to configuration (Strings map to an Apache Directory match whereas regular expressions create DirectoryMatch directives) However, as stated in the release notes, Puppet6 introduces a stricter YAML parser configuration forbidding this, leading to a compile-time server-side error:
Tried to load unspecified class: Regexp (file: /somewhere.pp, line: XX, column: YY) on node node.example.org
|
The obvious workaround we came up with is to use separate class parameters, one for String values and another one for Regexp values. As mentioned above this is not a blocker for us however we'd like to understand if perhaps this case has been overlooked when making the parser stricter or this is totally intentional (if this is the case perhaps a more detailed release notes would have helped). We'd be happy as well to know if you have any other suggestion apart from the parameter split to accomplish the same goal. Thanks. |