Ask Your Question
1

How to choose the provider on package command

asked 2014-09-25 11:58:56 -0600

Cesar Sturion gravatar image

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 flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
3

answered 2014-09-25 15:15:41 -0600

ramindk gravatar image

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.

edit flag offensive delete link more

Comments

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.

lavaman gravatar imagelavaman ( 2014-09-25 16:42:43 -0600 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2014-09-25 11:58:56 -0600

Seen: 236 times

Last updated: Sep 25 '14