The Puppet Labs Issue Tracker has Moved: https://tickets.puppetlabs.com

Bug #9655

Strange behaviour with collections and package providers

Added by Matt Dainty over 2 years ago. Updated about 2 years ago.

Status:Needs DecisionStart date:09/23/2011
Priority:NormalDue date:
Assignee:Nigel Kersten% Done:

0%

Category:package
Target version:-
Affected Puppet version:2.6.9 Branch:
Keywords:

We've Moved!

Ticket tracking is now hosted in JIRA: https://tickets.puppetlabs.com

This ticket may be automatically exported to the PUP project on JIRA using the button below:


Description

I have the following basic class:

class yum {

    yumrepo { "foo":
        ...
        notify => Exec["yum clean all"],
    }

    yumrepo { "bar":
        ...
        notify => Exec["yum clean all"],
    }

    exec { "yum clean all":
        refreshonly => true,
    }

    Exec["yum clean all"] -> Package <| provider == yum |>
}

So basically I’d like to run “yum clean all” after making any changes to the repository config and before I install any packages. However, I can’t get the dependency created unless I explicitly set the provider to yum in any individual package resources. So the following examples all fail:

On a CentOS host where yum is/should be the default provider:

node baz {
    include yum

    package { "vim": ensure => present }
}

Setting a resource default globally for all Packages:

Package {
    provider => yum,
}

node baz {
    include yum

    package { "vim": ensure => present }
}

Setting the resource default for all Packages just on the node in question:

node baz {
    Package {
        provider => yum,
    }

    include yum

    package { "vim": ensure => present }
}

The only way I got it to work is with:

node baz {
    include yum

    package { "vim":
        ensure   => present,
        provider => yum, # Ick
    }
}

I can also make it work by removing the condition “provider == yum” in the Package <| |> collection or even changing the == to !=. I’m verifying the presence of the dependency by looking at the graph .dot output as sometimes the random ordering can make it look like it’s working.

History

#1 Updated by Peter Meier over 2 years ago

I assume that his happens because the provider is not yet set (as it gets chosen automatically) when the packages are collected.

#2 Updated by R.I. Pienaar over 2 years ago

fwiw, this is more or less str8 from the docs http://docs.puppetlabs.com/guides/language_guide.html#chaining-resources which shows it’s at least intended to work

#3 Updated by James Turnbull over 2 years ago

  • Category set to package
  • Status changed from Unreviewed to Needs Decision
  • Assignee set to Nigel Kersten

Am I missing why this doesn’t work?

Also available in: Atom PDF