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

This issue tracker is now in read-only archive mode and automatic ticket export has been disabled. Redmine users will need to create a new JIRA account to file tickets using https://tickets.puppetlabs.com. See the following page for information on filing tickets with JIRA:

Bug #8263

stage setting does not apply to included classes

Added by Cristian Ciupitu almost 5 years ago. Updated over 3 years ago.

Status:RejectedStart date:07/06/2011
Priority:NormalDue date:
Assignee:-% Done:

0%

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

We've Moved!

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


Description

I want to configure yum (“yum.conf”, repos, mount NFS shares) before installing packages. For this I’m using the new stages feature.

site.pp:

stage { "yum": before => Stage["main"] }

nodes.pp:

node "intovps3.test-vms.tld" {
    ...
    include postfix
    include dovecot
    ...
    class { "yum": stage => yum }
}

The yum class is part of this puppet module.

# puppet agent --test --color=none
info: Retrieving plugin
info: Loading facts in mysql_version
info: Loading facts in mysql_exists
info: Loading facts in mysql_version
info: Loading facts in mysql_exists
info: Caching catalog for intovps3.test-vms.tld
info: Applying configuration version '1309980613'
info: create new repo epel in file /etc/yum.repos.d/epel.repo
notice: /Stage[yum]/Yum::Repos::Epel5/Yumrepo[epel]/descr: descr changed '' to 'Extra Packages for Enterprise Linux 5 - $basearch'
notice: /Stage[yum]/Yum::Repos::Epel5/Yumrepo[epel]/mirrorlist: mirrorlist changed '' to 'http://mirrors.fedoraproject.org/mirrorlist?repo=epel-5&arch=$basearch'
notice: /Stage[yum]/Yum::Repos::Epel5/Yumrepo[epel]/enabled: enabled changed '' to '1'
notice: /Stage[yum]/Yum::Repos::Epel5/Yumrepo[epel]/gpgcheck: gpgcheck changed '' to '1'
notice: /Stage[yum]/Yum::Repos::Epel5/Yumrepo[epel]/gpgkey: gpgkey changed '' to 'file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL'
info: changing mode of /etc/yum.repos.d/epel.repo from 600 to 644
notice: /Stage[main]/Dkim-milter::Install/Package[dkim-milter]/ensure: created
notice: /File[/etc/mail/dkim-milter/keys/default.private]/ensure: defined content as '{md5}67e26b82a9196c93f18750e942374fb7'
info: /File[/etc/mail/dkim-milter/keys]: Scheduling refresh of Service[dkim-milter]
--- /etc/mail/dkim-milter/keys/keylist  2010-02-02 20:44:22.000000000 +0200
+++ /tmp/puppet-file.6066.0 2011-07-06 22:55:08.795299087 +0300
@@ -1,2 +1,3 @@
 # *:example.com:selector
+*:intovps3.test-vms.tld:/etc/mail/dkim-milter/keys/default
notice: /File[/etc/mail/dkim-milter/keys/keylist]/content: content changed '{md5}ab6bb498c4a4a84026122f15b88b799a' to '{md5}8dd5d6216f01ed78f4f3cca731f69a72'
notice: /File[/etc/mail/dkim-milter/keys/keylist]/mode: mode changed '644' to '600'
info: /File[/etc/mail/dkim-milter/keys]: Scheduling refresh of Service[dkim-milter]
info: /File[/etc/mail/dkim-milter/keys]: Scheduling refresh of Service[dkim-milter]
notice: /File[/var/run/dkim-milter]/mode: mode changed '700' to '750'
info: /File[/var/run/dkim-milter]: Scheduling refresh of Service[postfix]
--- /etc/mail/dkim-milter/dkim-filter.conf  2010-02-02 20:44:22.000000000 +0200
+++ /tmp/puppet-file.6066.0 2011-07-06 22:55:09.615174447 +0300
@@ -553,7 +553,7 @@
 ##  The system has its own default which will be used (usually 022).
-# UMask            022
+UMask          002
 ##     default (none)
notice: /File[/etc/mail/dkim-milter/dkim-filter.conf]/content: content changed '{md5}76310fc7aef3edf31c8a2d4a415ffa56' to '{md5}a048231cf05d16700b5ef04e2bac19b0'
info: /File[/etc/mail/dkim-milter/dkim-filter.conf]: Scheduling refresh of Service[dkim-milter]
notice: /Stage[main]/Dkim-milter::Service/Service[dkim-milter]/ensure: ensure changed 'stopped' to 'running'
notice: /Stage[main]/Dkim-milter::Service/Service[dkim-milter]: Triggered 'refresh' from 4 events
info: create new repo media in file /etc/yum.repos.d/media.repo
notice: /Stage[main]/Yum::Repos::Media::Base/Yumrepo[media]/descr: descr changed '' to 'CentOS 5.6 - i386 media'
notice: /Stage[main]/Yum::Repos::Media::Base/Yumrepo[media]/baseurl: baseurl changed '' to 'file:///mnt/misc/CentOS-5.6-i386-DVD'
notice: /Stage[main]/Yum::Repos::Media::Base/Yumrepo[media]/enabled: enabled changed '' to '1'
notice: /Stage[main]/Yum::Repos::Media::Base/Yumrepo[media]/gpgcheck: gpgcheck changed '' to '0'
notice: /Stage[main]/Yum::Repos::Media::Base/Yumrepo[media]/gpgkey: gpgkey changed '' to 'file:///etc/pki/rpm-gpg/RPM-GPG-KEY-fedora-$basearch'
notice: /Stage[main]/Yum::Repos::Media::Base/Yumrepo[media]/metadata_expire: metadata_expire changed '' to '-1'
notice: /Stage[main]/Yum::Repos::Media::Base/Yumrepo[media]/priority: priority changed '' to '1'
notice: /Stage[main]/Yum::Repos::Media::Base/Yumrepo[media]/cost: cost changed '' to '500'
info: changing mode of /etc/yum.repos.d/media.repo from 600 to 644
notice: /Stage[main]/Yum::Repos::Ciupicri::Base/Mount[/mnt/misc/CentOS-ciupicri-repo]/ensure: ensure changed 'unmounted' to 'mounted'
info: /Stage[main]/Yum::Repos::Ciupicri::Base/Mount[/mnt/misc/CentOS-ciupicri-repo]: Scheduling refresh of Mount[/mnt/misc/CentOS-ciupicri-repo]
info: Mount[/mnt/misc/CentOS-ciupicri-repo](provider=parsed): Remounting
notice: /Stage[main]/Yum::Repos::Ciupicri::Base/Mount[/mnt/misc/CentOS-ciupicri-repo]: Triggered 'refresh' from 1 events
info: /Stage[main]/Yum::Repos::Ciupicri::Base/Mount[/mnt/misc/CentOS-ciupicri-repo]: Scheduling refresh of Mount[/mnt/misc/CentOS-ciupicri-repo]
notice: /Stage[main]/Yum::Repos::Media::Base/Mount[/mnt/misc/CentOS-5.6-i386-DVD]/ensure: ensure changed 'unmounted' to 'mounted'
info: /Stage[main]/Yum::Repos::Media::Base/Mount[/mnt/misc/CentOS-5.6-i386-DVD]: Scheduling refresh of Mount[/mnt/misc/CentOS-5.6-i386-DVD]
info: Mount[/mnt/misc/CentOS-5.6-i386-DVD](provider=parsed): Remounting
notice: /Stage[main]/Yum::Repos::Media::Base/Mount[/mnt/misc/CentOS-5.6-i386-DVD]: Triggered 'refresh' from 1 events
info: /Stage[main]/Yum::Repos::Media::Base/Mount[/mnt/misc/CentOS-5.6-i386-DVD]: Scheduling refresh of Mount[/mnt/misc/CentOS-5.6-i386-DVD]
notice: /Stage[main]/Yum::Cache::Base/Mount[/mnt/misc/yum-packages]/ensure: ensure changed 'unmounted' to 'mounted'
info: /Stage[main]/Yum::Cache::Base/Mount[/mnt/misc/yum-packages]: Scheduling refresh of Mount[/mnt/misc/yum-packages]
info: Mount[/mnt/misc/yum-packages](provider=parsed): Remounting
notice: /Stage[main]/Yum::Cache::Base/Mount[/mnt/misc/yum-packages]: Triggered 'refresh' from 1 events
info: /Stage[main]/Yum::Cache::Base/Mount[/mnt/misc/yum-packages]: Scheduling refresh of Mount[/mnt/misc/yum-packages]
info: create new repo tmz-puppet in file /etc/yum.repos.d/tmz-puppet.repo
notice: /Stage[main]/Yum::Repos::Tmz-puppet::El/Yumrepo[tmz-puppet]/descr: descr changed '' to 'Puppet for EL $releasever - $basearch'
notice: /Stage[main]/Yum::Repos::Tmz-puppet::El/Yumrepo[tmz-puppet]/baseurl: baseurl changed '' to 'http://tmz.fedorapeople.org/repo/puppet/epel/$releasever/$basearch'
notice: /Stage[main]/Yum::Repos::Tmz-puppet::El/Yumrepo[tmz-puppet]/enabled: enabled changed '' to '1'
notice: /Stage[main]/Yum::Repos::Tmz-puppet::El/Yumrepo[tmz-puppet]/gpgcheck: gpgcheck changed '' to '1'
notice: /Stage[main]/Yum::Repos::Tmz-puppet::El/Yumrepo[tmz-puppet]/gpgkey: gpgkey changed '' to 'http://tmz.fedorapeople.org/repo/RPM-GPG-KEY-tmz'
info: changing mode of /etc/yum.repos.d/tmz-puppet.repo from 600 to 644
notice: /Stage[main]/Dovecot::Install/Package[dovecot]/ensure: created
--- /etc/dovecot.conf   2009-01-21 10:22:57.000000000 +0200
+++ /tmp/puppet-file.6066.0 2011-07-06 22:55:26.051675719 +0300
@@ -18,6 +18,7 @@
 # Protocols we want to be serving: imap imaps pop3 pop3s
 ...
+  }
 }

 # If you wish to use another authentication server than dovecot-auth, you can
notice: /File[/etc/dovecot.conf]/content: content changed '{md5}e216b1f63a2c69703b2dad15f39fca25' to '{md5}839cee0cdc3dd48f40c53d8feb61d568'
info: /File[/etc/dovecot.conf]: Scheduling refresh of Service[dovecot]
notice: /Stage[main]/Dovecot::Service/Service[dovecot]/ensure: ensure changed 'stopped' to 'running'
notice: /Stage[main]/Dovecot::Service/Service[dovecot]: Triggered 'refresh' from 1 events
notice: /Stage[main]/Postfix::Install/Package[postfix]/ensure: created
notice: /File[/etc/postfix/sender_access]/ensure: defined content as '{md5}5a6132594bec1fbe75f1d7dd39381f0f'
info: /File[/etc/postfix/sender_access]: Scheduling refresh of Exec[postmap /etc/postfix/sender_access]
info: /File[/etc/postfix/sender_access]: Scheduling refresh of Service[postfix]
--- /etc/postfix/master.cf  2011-05-31 19:34:17.000000000 +0300
+++ /tmp/puppet-file.6066.0 2011-07-06 22:55:45.765678735 +0300
@@ -7,9 +7,11 @@
 #               (yes)   (yes)   (yes)   (never) (100)
 ...
 #  -o smtpd_tls_wrappermode=yes
notice: /File[/etc/postfix/master.cf]/content: content changed '{md5}d4534eeb2ca247e72ac14d615bd26e3a' to '{md5}d297f678311fc3e8e2a650e1f6a1cc6e'
info: /File[/etc/postfix/master.cf]: Scheduling refresh of Service[postfix]
--- /etc/postfix/main.cf    2011-05-31 19:34:17.000000000 +0300
+++ /tmp/puppet-file.6066.0 2011-07-06 22:55:46.505566255 +0300
@@ -107,7 +107,7 @@
 #inet_interfaces = all
 ...
 +non_smtpd_milters = $smtpd_milters
notice: /File[/etc/postfix/main.cf]/content: content changed '{md5}ea98973368322dcd5358082dc011038b' to '{md5}c2b893f924f081a9d0e40e61ce0f1636'
info: /File[/etc/postfix/main.cf]: Scheduling refresh of Service[postfix]
notice: /Stage[main]/Postfix::Config::Postmaps/Postfix::Postmap_config[sender_access]/Postfix::Postmap[sender_access]/Exec[postmap /etc/postfix/sender_access]: Triggered 'refresh' from 1 events
info: /Stage[main]/Postfix::Config::Postmaps/Postfix::Postmap_config[sender_access]/Postfix::Postmap[sender_access]/Exec[postmap /etc/postfix/sender_access]: Scheduling refresh of Service[postfix]
notice: /File[/etc/postfix/sender_login]/ensure: defined content as '{md5}d41d8cd98f00b204e9800998ecf8427e'
info: /File[/etc/postfix/sender_login]: Scheduling refresh of Exec[postmap /etc/postfix/sender_login]
info: /File[/etc/postfix/sender_login]: Scheduling refresh of Service[postfix]
notice: /Stage[main]/Postfix::Config::Sasl/Postfix::Postmap_config[sender_login]/Postfix::Postmap[sender_login]/Exec[postmap /etc/postfix/sender_login]: Triggered 'refresh' from 1 events
info: /Stage[main]/Postfix::Config::Sasl/Postfix::Postmap_config[sender_login]/Postfix::Postmap[sender_login]/Exec[postmap /etc/postfix/sender_login]: Scheduling refresh of Service[postfix]
notice: /Stage[main]/Postfix::Service/Service[postfix]/ensure: ensure changed 'stopped' to 'running'
notice: /Stage[main]/Postfix::Service/Service[postfix]: Triggered 'refresh' from 7 events
notice: /Stage[main]/Yum::Cache::Base/Mount[/var/cache/yum]/ensure: ensure changed 'unmounted' to 'mounted'
info: /Stage[main]/Yum::Cache::Base/Mount[/var/cache/yum]: Scheduling refresh of Mount[/var/cache/yum]
info: Mount[/var/cache/yum](provider=parsed): Remounting
notice: /Stage[main]/Yum::Cache::Base/Mount[/var/cache/yum]: Triggered 'refresh' from 1 events
info: /Stage[main]/Yum::Cache::Base/Mount[/var/cache/yum]: Scheduling refresh of Mount[/var/cache/yum]
notice: Finished catalog run in 62.04 seconds

As you can see some classes of the yum module are run in the main stage and after some packages have been already installed, e.g. dkim-milter.

I’m using puppet-2.6.9-1.el5 on the client and puppet-server-2.6.9-1.fc15.noarch on the server.

simple-example.tgz (1.39 KB) Greg Swift, 08/15/2012 03:50 pm

History

#1 Updated by Dan Bode almost 5 years ago

The real problem is that you are setting a stage on a class that includes other classes. Stages only works on resources that are actually declared in the class that is assigned to the stage.

This ticket is related to #5349 and #8040

#2 Updated by Cristian Ciupitu almost 5 years ago

Thank you for the feedback. Is there a workaround for my specific use case of configuring yum before installing any packages?

#3 Updated by James Turnbull over 4 years ago

  • Status changed from Unreviewed to Needs More Information
  • Assignee set to Dan Bode

#4 Updated by Dan Bode over 4 years ago

The way to work around this is to not compose classes inside of classes that you wish to apply stages to:

in the following code (from your example)


class yum {
    include repos::media
    include repos::tmz-puppet
    include repos::ciupicri
    include cache

    case $operatingsystem {
        "CentOS": { include repos::epel5 }
        "Scientific": { include repos::epel6 }
    }
}

the classes contained inside of the yum class will not have the yum stage applied to them.

the fix is to remove all of the uses of include from the yum class and inline all of the resources from the included classes into the actual yum class

#5 Updated by Dan Bode over 4 years ago

  • Status changed from Needs More Information to Accepted
  • Assignee deleted (Dan Bode)

#6 Updated by Nan Liu over 4 years ago

$stages is a variable that’s available. Here’s another work around:

class yum {
  Class { stage => $stage, }
  class { "repos::media": }
  class { "repos::tmz-puppet": }
  class { "repos::ciupicri": }

  ...
}

Now if class yum is in stage yum, all class declared in it will be in the same stage (however they can’t be declared again).

#7 Updated by eric sorenson almost 4 years ago

  • Status changed from Accepted to Rejected

Sweeping stages-related tickets — this one is not-to-be-fixed, there’s a reasonable workaround.

#8 Updated by Greg Swift over 3 years ago

For the record, I just had this bite me after upgrading from 2.6.3 to 2.6.13. Unfortunately, in my research on the issue I did not stumble on this, because my errors lead me down a different path (dependency cycle and a odd undefined require relationship). Nigel helped me through and pointed me to this ticket.

I’d argue that the ‘reasonable workaround’ is actually an ‘illogical workaround’.

If I include a class while stating it is in a stage, then everything in that class should inherit the stage, otherwise everything has to be re-written.

Where this falls apart is the re-use of existing modules without modifying them. If someone was to re-use the module I’m including in my attachment and set the puppet::client class in a stage before main, it would break and they would have to modify it.

In my case the module is very simple, and its now attached.

I’m not going to harp on the ‘it used to work’ side of this. I’m more concerned about the logical workflow and not having to go change all my includes/requires to class { ‘whatever’: stage => $stage }

#9 Updated by eric sorenson over 3 years ago

Greg—fair enough; I agree that the current workarounds for #8040 are not pretty.

This is getting some attention as part of #3691, which should make anchor pattern and related problems go away.

#10 Updated by Greg Swift over 3 years ago

is this a considered a workaround to this problem?

http://projects.puppetlabs.com/projects/puppet/wiki/Anchor_Pattern

Also available in: Atom PDF