define module($ensure) {
case $ensure {
enabled: { exec { "a2enmod":
command => "/usr/sbin/a2enmod $name",
logoutput => on_failure,
creates => "/etc/apache2/mods-enabled/$name.load",
notify => Service["apache2"],
}
}
disabled: { exec { "a2dismod":
command => "/usr/sbin/a2dismod $name",
logoutput => on_failure,
unless => "test ! -e
/etc/apache2/mods-enabled/$name.load",
notify => Service["apache2"],
}
}
default: { alert("Invalid option for apache::module.") }
}
}
I call it like so:
apache::module { "proxy_http": ensure => enabled }
This seems to work just fine as long as I only call it once. If I
call it multiple times, each with a different module name, I get this
error:
err: Could not retrieve catalog: Puppet::Parser::AST::Resource failed
with error ArgumentError: Duplicate definition: Exec[a2enmod] is
already defined in file /etc/puppet/manifests/classes/apache.pp at
line 12; cannot redefine at /etc/puppet/manifests/classes/apache.pp:12
I was under the impression that Exec expressly allows duplicate
definitions. What am I misunderstanding? Is there a better way to
structure this definition?
Thanks...
-Ben
I was under the impression that Exec expressly allows duplicate
definitions. What am I misunderstanding? Is there a better way to
structure this definition?
Perhaps I misunderstood what I read here:
http://reductivelabs.com/trac/puppet/wiki/TypeReference#exec
Not only does it seem to be saying that an exec is allowed to have a
duplicate title/name, but the example seems to be demonstrating
exactly that. Am I misreading it?
> exec { "a2enmod-$name":
> command => '/bin/whatever',
I'll give that a shot. Thanks!
-Ben
I agree with you, definately. I suspect, but do not know, that the
cwds need to be different in that case.
-Robin
--
They say: "The first AIs will be built by the military as weapons."
And I'm thinking: "Does it even occur to you to try for something
other than the default outcome?" -- http://shorl.com/tydruhedufogre
http://www.digitalkingdom.org/~rlpowell/ *** http://www.lojban.org/