Why not ???
Chris
NB: this works under puppet v3
@Eric: what version are you running? For me facter -p operatingsystemmajrelease => 6 and putting either single or double quotes (or /5/, /6/ for regex match) around the 5 &6 in the pp file gives Error: Could not retrieve catalog from remote server: Could not intern from text/pson: Invalid tag "php_packages = " Warning: Not using cache on failed catalog Error: Could not retrieve catalog; skipping run
@Dylan - here you go
cat install.pp class php::classes::install { notify { "operatingsystemmajrelease = $operatingsystemmajrelease": } case $operatingsystemmajrelease { "5": { notify { "in case 5": } $php_packages = [ 'php53', 'php53-cli', 'php53-common', 'php53-ldap', 'php53-pgsql', 'php53-pdo', 'php53-mysql', ] } "6": { notify { "in case 6": } notify { "operatingsystemmajrelease6 = $operatingsystemmajrelease": } $php_packages = [ 'php', 'php-cli', 'php-common', 'php-ldap', 'php-pgsql', 'php-pdo', 'php-mysql', ] } default: { notify { "in default case": } # fail("Failed to match operatingsystemmajrelease $operatingsystemmajrelease") } } notify { "php_packages = $php_packages": } } @Dylan 2: Server: puppetserver version: 2.4.0 puppet agent -V 4.5.0 Client puppet agent -V 3.3.1 Still getting the '... invalid tag ..' msg if using above with-quotes method.. Without quotes it drops into the default case ...
It gets worse; apparently it's 'consistent'
class tuned {
if $operatingsystemmajrelease == 6 {
include 'tuned::classes::install'
include 'tuned::classes::configuration'
include 'tuned::classes::service'
}
}
That simple class does nothing as run.
If I comment out start/end 'if' statements, (ie just call the 'include's ), then it will run them..
aarrghh - Help...
================================================================
Ok, so I had a week off and came back with a more relaxed mind and did some careful testing
It turns out there were 2 issues which got mixed in together.
My original/actual problem (testing against an integer literal) is solved by using either single or double quotes around the integer literal.
Where I got distracted was trying to debug by 'notify{}'ing an array, which it appears can't be done. This throws an 'invalid tag...' error as shown above.
You can however notify{} individual elements .
I did try "array sectioning" https://docs.puppet.com/puppet/latest/reference/lang_data_array.html#array-sectioning but couldn't make it work for eg [0,-1]; I'm guessing its because the client end is too old. Only wanted it for debugging anyway, so not a problem as such.
Anyway, thanks for all the suggestions etc - think I'm going to call this one 'Done' for now
Cheers
Chris