[Puppet Users] Problem dealing with multi role servers/manifests. resource already declared.

trey85stang
Wed, 20 Jun 2012 22:20:38 -0000

Hey All,


Im running into a road block with a server that is going to to be
multi role.

Example:

I want to run a nagios server and a repo server on one box.

My nagios manifest has two services defined:

class nagios::server {
...
  service { nagios:
    ensure => running,
    ...
  }

  service { httpd:
    ensure => running
    ...
  }
...
}


Now I also want to assign my reposerver manifest to a server already
running the nagios manifest

class repo::server {
  ...
  service { httpd:
    ensure => running
  }
...
}


Now in each case I have files where httpd is notified to refresh...
Is there a way to work around this without creating a custom module
just for this one case? As you can see from the below error message I
tried changing the name and using an alias.. but it does not like that
either.

There error message:
Could not retrieve catalog from remote server: Error 400 on SERVER:
Puppet::Parser::AST::Resource failed with error ArgumentError: Cannot
alias Service[reposerver-httpd] to ["httpd"] at /etc/puppet/
environments/dev/modules/repo/manifests/init.pp:113; resource
["Service", "httpd"] already declared at
/etc/puppet/environments/dev/
modules/nagios/manifests/init.pp:217 at /etc/puppet/environments/dev/
modules/opservers/manifests/init.pp:113 on node mynode.com