Barry Jaspan
2011-Jan-24 19:57 UTC
[Puppet Users] Two packages, different providers, same name
I have encountered what might be a bug in the package resource type. I''m using puppet 0.25.5 so perhaps it has been fixed in a later version. The problem involves installing a package from two different providers (e.g.: apt and get) with the same name in the provider''s environment. For example, suppose I want puppet to perform the equivalent of "apt-get install foo" and "gem install foo" on the same server. I might write: package { "foo": provider => "apt", ensure => installed, } package { "foo": provider => "gem", ensure => installed, } That will not work; puppet correctly reports that Package[foo] is multiply defined. To solve that, I change the title of both resources: package { "apt_foo": name => "foo", provider => "apt", ensure => installed, } package { "gem_foo": name => "foo", provider => "gem", ensure => installed, } This does not work either. Puppet gives the error "Error 400 on SERVER: Puppet::Parser::AST::Resource failed with error ArgumentError: Cannot alias Package[gem_foo] to foo; resource Package[foo] already exists." It says "resource Package[foo] already exists" but it does not. Package[gem_foo] and Package[apt_foo] exist. Is this a bug in the package resource/puppet or am I confused about something? Thanks, Barry -- 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+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
Nan Liu
2011-Jan-24 20:28 UTC
Re: [Puppet Users] Two packages, different providers, same name
On Mon, Jan 24, 2011 at 11:57 AM, Barry Jaspan <barry.jaspan@acquia.com> wrote:> I have encountered what might be a bug in the package resource type. I''m > using puppet 0.25.5 so perhaps it has been fixed in a later version. > > The problem involves installing a package from two different providers > (e.g.: apt and get) with the same name in the provider''s environment. For > example, suppose I want puppet to perform the equivalent of "apt-get install > foo" and "gem install foo" on the same server. I might write: > > package { "foo": > provider => "apt", > ensure => installed, > } > package { "foo": > provider => "gem", > ensure => installed, > } > > That will not work; puppet correctly reports that Package[foo] is multiply > defined. To solve that, I change the title of both resources: > > package { "apt_foo": > name => "foo", > provider => "apt", > ensure => installed, > } > package { "gem_foo": > name => "foo", > provider => "gem", > ensure => installed, > } > > This does not work either. Puppet gives the error "Error 400 on SERVER: > Puppet::Parser::AST::Resource failed with error ArgumentError: Cannot alias > Package[gem_foo] to foo; resource Package[foo] already exists." > > It says "resource Package[foo] already exists" but it does not. > Package[gem_foo] and Package[apt_foo] exist. Is this a bug in the package > resource/puppet or am I confused about something? >This is a restriction for most resource types. Puppet not only check for unique type and title pair, but also enforces unique namevar per resource type (since it identifies the resource on the system and we can not describe two different desire state for the same resource). The namevar for packages is the package name so it can not contain duplicates. As an example with file resource, even if you provide two different title, you can not manage the same file path (path is namevar). I can see it may be desirable to manage different package providers so you can specify apt_foo absent, and gem_foo present. In this case, the package provider needs to be rewritten like cron (where the command isn''t the namevar), but rather a composite of the package provider and package name uniquely identifies the package on the system. Composites have been provided in 2.6.0 as feature #1621, but I''m not aware of updates to the package provider to take advantage of it yet. Without composites, I don''t see any possibility for this feature implemented for 0.25.5. #1398 was accepted again but not on the roadmap yet. I suggest anyone monitoring this mailing list to vote up this request unless someone sees another ticket with more appropriate info. Thanks, Nan -- 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+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
Marcin Deranek
2011-Jan-26 15:34 UTC
[Puppet Users] Re: Two packages, different providers, same name
This should work: package { "foo": ensure => installed } package { "foo-1.2": ensure => installed } or package { "foo": ensure => installed } package { "foo.$architecture": ensure => installed } on CentOS. Possibly other OS''s should have similar workaround(s) (not sure if it will work in the future though). -- 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+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.