Ask Your Question

I do not understand this puppet code.

asked 2014-06-13 14:40:46 -0600

Red Cricket gravatar image


I was looking at some puppet code and I saw this snippet of code ...

File {
    require => Package['ceilometer-common'],

... I wonder why this was not written as:

   package { 'ceilometer-common':

Is this a technique for ensure that the ceilometer-common package is installed before anything else happens?

... later on in the code there is this snippet ...

if ! defined(Package['ceilometer-common']) {
    package { 'ceilometer-common':
      ensure => $package_ensure,
      name   => $::ceilometer::params::common_package_name,

  Package['ceilometer-common'] -> Ceilometer_config<||>

... I assume the author is trying to avoid a 're-definition' error of the package type with the if ! defined ... clause, but I have never seen the <||> operator before.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2014-06-13 15:45:53 -0600

cwalstrom gravatar image

updated 2014-06-13 15:46:43 -0600

The first snippet assigns a default require for all File resources defined in the scope of the manifest (and any manifests that it include's). You'll likely see a file {'somename': somewhere else in that manifest. That is where the package will initially be required.

You are correct in assuming that the ! defined(Package... pattern is intended to only instantiate the ceilometer-common package if not already defined. I've had very mixed success with this pattern.

Finally, the Ceilometer_config<||> statement is a resource collector. The -> arrow indicates that puppet should place an explicit order, installing the package first, then collecting the resource collection.

edit flag offensive delete link more

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


Asked: 2014-06-13 14:40:46 -0600

Seen: 151 times

Last updated: Jun 13 '14