5

I'm trying to install two things:

A PHP-PECL module called "mongo", and a package on yum called "mongo". They'll need to use the "name" variable to know what the real name of the package is, but the alias puppet creates using this name is making it impossible to handle more than one provider.

I knew I'd have to give them different resource names, so naturally, I did this:

package { "php-mongo" :
    ensure   => installed,
    provider => 'pecl',
    name     => 'mongo'
}

package { "yum-mongo" :
    ensure   => installed,
    provider => 'yum',
    name     => 'mongo'
}

Because I get the error:

Cannot alias Package[php-mongo] to ["mongo"] at /etc/puppet/environments/testing/modules/packages/manifests/install.pp:52; resource ["Package", "mongo"] already declared at /etc/puppet/environments/testing/modules/packages/manifests/install.pp:52

How can I make this work without patching stdlib? Do I need to patch my providers instead, so they can remove a prepended "php-" if I include it in the name just to avoid a conflict? That seems dumb!

Upon research, this is an old, old bug, but I'm not finding any way around it!

Bug 1398

Thanks!

Gritty Kitty
  • 297
  • 2
  • 12
  • 2
    I ended up using a defined type to append the package name to the "name" attribute of the package, then added custom providers to remove it at runtime. Laaaaame. – Gritty Kitty Jan 03 '14 at 19:45

1 Answers1

3

Another workaround is to use an Exec to install one of the packages via its respective package management utility. Obviously this is not ideal, but it gets both packages installed without the name conflict.

smstone
  • 61
  • 3
  • 1
    That's definitely a solution, but the point is to do this elegantly, in a way that makes use of puppet as it was intended: To describe resources, not herd execs. – Gritty Kitty Jan 14 '14 at 22:45