Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I install two packages with the same name but two different providers in puppet?

Tags:

package

puppet

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!

like image 520
Gritty Kitty Avatar asked Oct 20 '22 18:10

Gritty Kitty


1 Answers

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.

like image 125
smstone Avatar answered Oct 24 '22 00:10

smstone