I am not sure how to word this questions so please suggest an edit if you feels its inappropriate.
I am trying to extend existing puppet modules with support of different OS. I have ran out into a small problem which I am not sure how I could solve in an elegant way. In params.pp
file there is such definition of OS-specific packages to install:
case $::osfamily {
'RedHat': {
$package_server = 'mariadb-server'
$package_client = 'mariadb'
$php_package_name = 'php-mysql'
}
...
The module is written in such way that whole configuration depends on having $php_package_name
installed. I want to exnted this module for different OS, which does not have a separate mysql package for php, thus I set $php_package_name
variable to undef
. This brings a problem, that puppet tries to install Package[undef]
.
What would be a good way to prevent it? My thoughts so far war setting it to false and have whole definition of $php_package_name
fire only if $php_package_name != false
. Maybe there is a better way?
$php_package_name
tofalse
is a solution, that will work 50% of time. The other 50% times you will have the if$php_package_name != false
evaluated first, and$php_package_name = false
only later: unfortunately Puppet doesn't use the information where a variable is defined and where it is used to do a correct variable definitons' parsing. See: serverfault.com/questions/590762/…