How to choose the provider on package command

Hi, guys,

I need a help. I want to choose the provider on package command, for example:

  case $operatingsystem { centos: {$provider = "yum" }
# Note that these matches are case-insensitive.
redhat: { $provider = "yum" } debian: {$provider = "apt" }
ubuntu: { $provider = "apt" } default: { fail("Unrecognized operating system for webserver") } package { 'autocomps-basic-desktop_NetworkManager-gnome' : name => 'NetworkManager-gnome', ensure => installed, provider => '${provider}'
}


When I execute the command puppet --test --noop, occurs the message below:

Error: Could not retrieve catalog from remote server: Error 400 on SERVER: Could not match ${provider} What's wrong in the command above ? edit retag close merge delete 1 Answer Sort by » oldest newest most voted provider => '${provider}' should be provider => "${provider}" Double quotes are required for interpolation. Also you'd be better off setting a default once in manifests/site.pp. I'd use some regex and the osfamily fact to make it simpler too. Package { provider =>$osfamily ? {
/(?i:redhat)/ => 'yum',
/(?i:debian)/ => 'apt',
}


Additionally you might choose to skip doing this altogether as Puppet will use apt, yum, etc by default. Unless you want to specifically override a default, I'd leave it alone.

more

Yeah, you really shouldn't have to be doing this. Provider is not a required parameter for package, and the way you are doing it is exactly how the provider does it anyway.

( 2014-09-25 16:42:43 -0500 )edit

Stats

Seen: 254 times

Last updated: Sep 25 '14