I'm working on a definition for activating/deactivating Apache modules
on an Ubuntu system.  Inside my Apache class I have this definition:

    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

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To post to this group, send email to puppet-users@googlegroups.com
To unsubscribe from this group, send email to 
puppet-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/puppet-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to