I am trying to configure Apache Virtual Hosts with Puppet and have been trying different things with little success.
I have defined a node as the following :
node 'test1.cob' inherits serveurClient {
$smcvhost = 'all'
}
The serveurClient class includes the apache class. This works fine as Apache gets installed and all the configuration gets applied correctly, except the virtual hosts.
The configuration relating to the virtual hosts is the following :
class apache::config {
File{
require => Class["apache::install"],
notify => Class["apache::service"],
ensure => present,
owner => "www-data",
group => "www-data",
mode => 755
}
...
if ( $smcvhost == 'belleville' ) or ( $smcvhost == 'all' ) {
apache::smcvhost{'belleville':
client => 'belleville',
}
}
...
}
The apache::smcvhost definition works correctly because if I specify it directly in the node without the condition, the virtual host gets created correctly with no errors. If I remove the if statement, it will also get created correctly. I have tried only specifying the second condition but that did not make it work.
When this fails to be executed, I do not get any error. The puppet report just ignores this configuration part.
I am thinking that this is some sort of variable scoping problem but from what I have read, this practice seems correct and I imagine puppet would give me some error if I tried to evaluate a non-existing variable.