another latest issue

27 views
Skip to first unread message

asav...@asdco.ru

unread,
Apr 14, 2015, 5:30:20 PM4/14/15
to puppet...@googlegroups.com
Hi.

I have multiple modules/classes used in site.pp manifest.

in site.pp i've some code like this:

  Package <| title != 'yum-plugin-priorities' |> { require => Exec['clean_yum_cache'] }
  Yumrepo<||> { before => Exec['clean_yum_cache'] }
  exec { "clean_yum_cache":
    command   => "yum clean all",
    path => "/sbin:/bin:/usr/sbin:/usr/bin",
  }

in custom puppet type "A"(dsl, not ruby), which definded in site.pp i've code like this

      if ! defined(Versionunlock[$::billing_rpm_name]) {
        versionunlock { $::billing_rpm_name:
          before => Package[$::billing_rpm_name],
        }
        versionlock { "${::billing_rpm_name}-${::cb_version}":
          require => Package[$::billing_rpm_name],
        }
      }

* versionlock- my custom ruby provides for use yum versionlock plugin.

and in other manifest, included in type A, like this code:

  package {$::billing_rpm_name:
   ensure => $cb_version,
   require => [Package['zeromq'],Yumrepo['addons']],
  }


If at first I run puppet agent - package $::billing_rpm_name  will not be updated, this package update only at secondry run puppet agent.
But I need that package to be updatet at first run puppet agent.

If i run custom manifest with this code:

  package {$::billing_rpm_name:
   ensure => $cb_version,
   require => [Package['zeromq'],Yumrepo['addons']],
  }
  Package <| title != 'yum-plugin-priorities' |> { require => Exec['clean_yum_cache'] }
  Yumrepo<||> { before => Exec['clean_yum_cache'] }
  exec { "clean_yum_cache":
    command   => "yum clean all",
    path => "/sbin:/bin:/usr/sbin:/usr/bin",
  }

Package is updated immediately.

Please tell me what could be wrong?

asav...@asdco.ru

unread,
Apr 15, 2015, 8:44:02 AM4/15/15
to puppet...@googlegroups.com
rectification:

$cb_version = latest
 
in custom puppet type "A"(dsl, not ruby), which definded in site.pp i've code like this

type A declared in site.pp , defined in custom module.

jcbollinger

unread,
Apr 15, 2015, 1:36:32 PM4/15/15
to puppet...@googlegroups.com


There are all sorts of things that could be wrong. I started to make a long list, but you give the impression of having paid attention to most of the possibilities I thought of.  The most likely thing you might not have thought of is that the 'yum' package provider determines very early in a run which is the "latest" version of each package.  To the extent that that determination depends on a certain package (e.g. yum-plugin-priorities) being installed, you may get a different determination of the latest available versions if you rely on Puppet to ensure that package installed.

This is a chicken-and-egg problem: Puppet must evaluate the latest package versions prior to installing any package, but it may get a different result at that time than it would if it performed the evaluation later in the run.  It is also, however, completely consistent with Puppet's execution model, which relies on computing the desired target node state from the initial node state.  It cannot be solved within Puppet, at least not in a single Puppet run.

To overcome a problem such as this so that the very first Puppet run puts the machine in the desired final state, you need to work outside Puppet, by ensuring that the packages needed for Puppet to do the job are installed during your provisioning process, prior to the first run.  Alternatively, you could embrace use of two Puppet runs when you first bring up a machine.  You might even use custom facts to determine whether the needed base packages are installed, and in that case generate only a minimal catalog sufficient to install those packages.


John

Reply all
Reply to author
Forward
0 new messages