Hi Daniel,
it looks indeed that it works in some/most cases - I tried to create a
minimal test class to check it using only file resources and it works
as you say - and as I want. So I have to post here one of the actual
not so minimal use case which depend on the expected behaviour.
---------------------------------------------
#Class to setup specific yum repos
class ssa::yum {
class { '::yum': }
class { 'yum::epel': enable => true }
class { 'yum::rpmforge': enable => true }
class { 'yum::nixval': enable => true }
class { 'yum::cloudera': enable => true }
class { 'yum::zabbix': enable => false }
class { 'yum::elff': enable => false }
}
---------------------------------------------
#Class which has yum::repo define
class yum {
file { "/etc/yum.repos.d":
ensure => directory,
purge => true,
recurse => true,
owner => 'root',
group => 'root',
mode => 0755,
source => "puppet:///yum/yum.repos.d"
}
define repo ( $descr='absent', $enabled='0', $baseurl='absent',
$mirrorlist='absent', $gpgcheck='absent', $gpgkey='absent',
$exclude='absent', $includepkgs='absent' ) {
if $gpgkey != 'absent' and ! defined(File["${gpgkey}"]) {
$key = "file://${gpgkey}"
file { "${gpgkey}":
owner => root,
group => root,
mode => 0444,
source => "puppet:///modules/yum${gpgkey}",
before => Yumrepo["${name}"]
}
exec { "rpm --import ${gpgkey}":
path => "/bin:/sbin:/usr/bin:/usr/sbin",
subscribe => File["${gpgkey}"],
refreshonly => true
}
}
else {
$key = 'absent'
}
yumrepo { "${name}":
descr => $descr,
enabled => $enabled,
baseurl => $baseurl,
mirrorlist => $mirrorlist,
failovermethod => 'priority',
gpgcheck => $gpgcheck,
gpgkey => $key,
exclude => $exclude,
includepkgs => $includepkgs,
require => File["/etc/yum.repos.d"]
}
}
}
----------------------------------------------
#Sample class that uses yum::repo define
class yum::epel( $enable = true ) {
if $enable { $enabled = '1' }
else { $enabled = '0' }
yum::repo { "epel":
descr => 'Extra Packages for Enterprise Linux 5 - $basearch',
enabled => $enabled,
mirrorlist => '
http://mirrors.fedoraproject.org/mirrorlist?
repo=epel-5&arch=$basearch',
gpgcheck => '1',
gpgkey => '/etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL'
}
}
----------------------------------------------
In the log below you can clearly see that puppet first purges all
managed(and unmanaged) files from the /etc/yum.repos.d
and the populates it again with same managed files. The exact same
purge/populate happens on each run.
----------------------------------------------
[root@mon1a yum.repos.d]# puppet agent --verbose --no-daemonize
notice: Starting Puppet client version 2.7.1
info: Retrieving plugin
info: Loading facts in ssa
info: Loading facts in ssa
info: Caching catalog for mon1a.internal
info: Applying configuration version '1314659756'
info: FileBucket got a duplicate file {md5}
f9994d7bb9f7daf111bcb4c2b1363017
info: /File[/etc/yum.repos.d/nixval.repo]: Filebucketed /etc/
yum.repos.d/nixval.repo to puppet with sum
f9994d7bb9f7daf111bcb4c2b1363017
notice: /File[/etc/yum.repos.d/nixval.repo]/ensure: removed
info: FileBucket got a duplicate file {md5}
7dc04195bbd206d01b59068f8742a940
info: /File[/etc/yum.repos.d/rpmforge-extras.repo]: Filebucketed /etc/
yum.repos.d/rpmforge-extras.repo to puppet with sum
7dc04195bbd206d01b59068f8742a940
notice: /File[/etc/yum.repos.d/rpmforge-extras.repo]/ensure: removed
info: FileBucket got a duplicate file {md5}
75377ca8231483ff6e7ca8f5305f1bcc
info: /File[/etc/yum.repos.d/cloudera-cdh3.repo]: Filebucketed /etc/
yum.repos.d/cloudera-cdh3.repo to puppet with sum
75377ca8231483ff6e7ca8f5305f1bcc
notice: /File[/etc/yum.repos.d/cloudera-cdh3.repo]/ensure: removed
info: FileBucket got a duplicate file {md5}
e0c282cec3ec08ec8af395429a2f1cc0
info: /File[/etc/yum.repos.d/elff.repo]: Filebucketed /etc/yum.repos.d/
elff.repo to puppet with sum e0c282cec3ec08ec8af395429a2f1cc0
notice: /File[/etc/yum.repos.d/elff.repo]/ensure: removed
info: FileBucket got a duplicate file {md5}
e797e55a1390785b478c017130821404
info: /File[/etc/yum.repos.d/danny.repo]: Filebucketed /etc/
yum.repos.d/danny.repo to puppet with sum
e797e55a1390785b478c017130821404
notice: /File[/etc/yum.repos.d/danny.repo]/ensure: removed
info: FileBucket adding {md5}c0fcc5653e77aa5c74a47c41e2ed34bb
info: /File[/etc/yum.repos.d/rpmforge.repo]: Filebucketed /etc/
yum.repos.d/rpmforge.repo to puppet with sum
c0fcc5653e77aa5c74a47c41e2ed34bb
notice: /File[/etc/yum.repos.d/rpmforge.repo]/ensure: removed
info: FileBucket got a duplicate file {md5}
e318df8a6487d6cee2c9e2ed7b046225
info: /File[/etc/yum.repos.d/epel.repo]: Filebucketed /etc/yum.repos.d/
epel.repo to puppet with sum e318df8a6487d6cee2c9e2ed7b046225
notice: /File[/etc/yum.repos.d/epel.repo]/ensure: removed
info: create new repo rpmforge in file /etc/yum.repos.d/rpmforge.repo
notice: /Stage[main]/Yum::Rpmforge/Yum::Repo[rpmforge]/
Yumrepo[rpmforge]/descr: descr changed '' to 'RHEL $releasever -
RPMforge.net - dag'
notice: /Stage[main]/Yum::Rpmforge/Yum::Repo[rpmforge]/
Yumrepo[rpmforge]/mirrorlist: mirrorlist changed '' to 'http://
apt.sw.be/redhat/el5/en/mirrors-rpmforge'
notice: /Stage[main]/Yum::Rpmforge/Yum::Repo[rpmforge]/
Yumrepo[rpmforge]/baseurl: baseurl changed '' to '
http://apt.sw.be/
redhat/el5/en/$basearch/rpmforge'
notice: /Stage[main]/Yum::Rpmforge/Yum::Repo[rpmforge]/
Yumrepo[rpmforge]/enabled: enabled changed '' to '1'
notice: /Stage[main]/Yum::Rpmforge/Yum::Repo[rpmforge]/
Yumrepo[rpmforge]/gpgcheck: gpgcheck changed '' to '1'
notice: /Stage[main]/Yum::Rpmforge/Yum::Repo[rpmforge]/
Yumrepo[rpmforge]/gpgkey: gpgkey changed '' to 'file:///etc/pki/rpm-
gpg/RPM-GPG-KEY-rpmforge-dag'
notice: /Stage[main]/Yum::Rpmforge/Yum::Repo[rpmforge]/
Yumrepo[rpmforge]/exclude: exclude changed '' to 'nagios-plugins*
rrdtool* perl-rrdtool'
notice: /Stage[main]/Yum::Rpmforge/Yum::Repo[rpmforge]/
Yumrepo[rpmforge]/failovermethod: failovermethod changed '' to
'priority'
info: changing mode of /etc/yum.repos.d/rpmforge.repo from 600 to 644
info: create new repo rpmforge-extras in file /etc/yum.repos.d/
rpmforge-extras.repo
notice: /Stage[main]/Yum::Rpmforge/Yum::Repo[rpmforge-extras]/
Yumrepo[rpmforge-extras]/descr: descr changed '' to 'RHEL $releasever
- RPMforge.net - extras'
notice: /Stage[main]/Yum::Rpmforge/Yum::Repo[rpmforge-extras]/
Yumrepo[rpmforge-extras]/mirrorlist: mirrorlist changed '' to 'http://
apt.sw.be/redhat/el5/en/mirrors-rpmforge-extras'
notice: /Stage[main]/Yum::Rpmforge/Yum::Repo[rpmforge-extras]/
Yumrepo[rpmforge-extras]/baseurl: baseurl changed '' to 'http://
apt.sw.be/redhat/el5/en/$basearch/extras'
notice: /Stage[main]/Yum::Rpmforge/Yum::Repo[rpmforge-extras]/
Yumrepo[rpmforge-extras]/enabled: enabled changed '' to '1'
notice: /Stage[main]/Yum::Rpmforge/Yum::Repo[rpmforge-extras]/
Yumrepo[rpmforge-extras]/gpgcheck: gpgcheck changed '' to '1'
notice: /Stage[main]/Yum::Rpmforge/Yum::Repo[rpmforge-extras]/
Yumrepo[rpmforge-extras]/failovermethod: failovermethod changed '' to
'priority'
info: changing mode of /etc/yum.repos.d/rpmforge-extras.repo from 600
to 644
info: create new repo cloudera-cdh3 in file /etc/yum.repos.d/cloudera-
cdh3.repo
notice: /Stage[main]/Yum::Cloudera/Yum::Repo[cloudera-cdh3]/
Yumrepo[cloudera-cdh3]/descr: descr changed '' to 'Cloudera's
Distribution for Hadoop, Version 3'
notice: /Stage[main]/Yum::Cloudera/Yum::Repo[cloudera-cdh3]/
Yumrepo[cloudera-cdh3]/mirrorlist: mirrorlist changed '' to 'http://
archive.cloudera.com/redhat/cdh/3/mirrors'
notice: /Stage[main]/Yum::Cloudera/Yum::Repo[cloudera-cdh3]/
Yumrepo[cloudera-cdh3]/enabled: enabled changed '' to '1'
notice: /Stage[main]/Yum::Cloudera/Yum::Repo[cloudera-cdh3]/
Yumrepo[cloudera-cdh3]/gpgcheck: gpgcheck changed '' to '1'
notice: /Stage[main]/Yum::Cloudera/Yum::Repo[cloudera-cdh3]/
Yumrepo[cloudera-cdh3]/gpgkey: gpgkey changed '' to 'file:///etc/pki/
rpm-gpg/RPM-GPG-KEY-cloudera'
notice: /Stage[main]/Yum::Cloudera/Yum::Repo[cloudera-cdh3]/
Yumrepo[cloudera-cdh3]/failovermethod: failovermethod changed '' to
'priority'
info: changing mode of /etc/yum.repos.d/cloudera-cdh3.repo from 600 to
644
info: create new repo nixval in file /etc/yum.repos.d/nixval.repo
notice: /Stage[main]/Yum::Nixval/Yum::Repo[nixval]/Yumrepo[nixval]/
descr: descr changed '' to 'Red Hat Enterprise 5 - NIXVAL - Updates'
notice: /Stage[main]/Yum::Nixval/Yum::Repo[nixval]/Yumrepo[nixval]/
baseurl: baseurl changed '' to '
http://repo.nixval.com/nixval-centos/5/
updates'
notice: /Stage[main]/Yum::Nixval/Yum::Repo[nixval]/Yumrepo[nixval]/
enabled: enabled changed '' to '1'
notice: /Stage[main]/Yum::Nixval/Yum::Repo[nixval]/Yumrepo[nixval]/
gpgcheck: gpgcheck changed '' to '0'
notice: /Stage[main]/Yum::Nixval/Yum::Repo[nixval]/Yumrepo[nixval]/
failovermethod: failovermethod changed '' to 'priority'
info: changing mode of /etc/yum.repos.d/nixval.repo from 600 to 644
info: create new repo epel in file /etc/yum.repos.d/epel.repo
notice: /Stage[main]/Yum::Epel/Yum::Repo[epel]/Yumrepo[epel]/descr:
descr changed '' to 'Extra Packages for Enterprise Linux 5 -
$basearch'
notice: /Stage[main]/Yum::Epel/Yum::Repo[epel]/Yumrepo[epel]/
mirrorlist: mirrorlist changed '' to '
http://mirrors.fedoraproject.org/
mirrorlist?repo=epel-5&arch=$basearch'
notice: /Stage[main]/Yum::Epel/Yum::Repo[epel]/Yumrepo[epel]/enabled:
enabled changed '' to '1'
notice: /Stage[main]/Yum::Epel/Yum::Repo[epel]/Yumrepo[epel]/gpgcheck:
gpgcheck changed '' to '1'
notice: /Stage[main]/Yum::Epel/Yum::Repo[epel]/Yumrepo[epel]/gpgkey:
gpgkey changed '' to 'file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL'
notice: /Stage[main]/Yum::Epel/Yum::Repo[epel]/Yumrepo[epel]/
failovermethod: failovermethod changed '' to 'priority'
info: changing mode of /etc/yum.repos.d/epel.repo from 600 to 644
info: create new repo danny in file /etc/yum.repos.d/danny.repo
notice: /Stage[main]/Yum::Zabbix/Yum::Repo[danny]/Yumrepo[danny]/
descr: descr changed '' to 'Dan Horak's repo'
notice: /Stage[main]/Yum::Zabbix/Yum::Repo[danny]/Yumrepo[danny]/
baseurl: baseurl changed '' to '
http://fedora.danny.cz/danny-el/
$releasever/$basearch'
notice: /Stage[main]/Yum::Zabbix/Yum::Repo[danny]/Yumrepo[danny]/
enabled: enabled changed '' to '1'
notice: /Stage[main]/Yum::Zabbix/Yum::Repo[danny]/Yumrepo[danny]/
gpgcheck: gpgcheck changed '' to '1'
notice: /Stage[main]/Yum::Zabbix/Yum::Repo[danny]/Yumrepo[danny]/
gpgkey: gpgkey changed '' to 'file:///etc/pki/rpm-gpg/RPM-GPG-KEY-
danny'
notice: /Stage[main]/Yum::Zabbix/Yum::Repo[danny]/Yumrepo[danny]/
failovermethod: failovermethod changed '' to 'priority'
info: changing mode of /etc/yum.repos.d/danny.repo from 600 to 644
info: create new repo elff in file /etc/yum.repos.d/elff.repo
notice: /Stage[main]/Yum::Elff/Yum::Repo[elff]/Yumrepo[elff]/descr:
descr changed '' to 'Enterprise Linux Fast Forward 5 - $basearch'
notice: /Stage[main]/Yum::Elff/Yum::Repo[elff]/Yumrepo[elff]/baseurl:
baseurl changed '' to '
http://download.elff.bravenet.com/5/$basearch'
notice: /Stage[main]/Yum::Elff/Yum::Repo[elff]/Yumrepo[elff]/enabled:
enabled changed '' to '0'
notice: /Stage[main]/Yum::Elff/Yum::Repo[elff]/Yumrepo[elff]/gpgcheck:
gpgcheck changed '' to '1'
notice: /Stage[main]/Yum::Elff/Yum::Repo[elff]/Yumrepo[elff]/gpgkey:
gpgkey changed '' to 'file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ELFF'
notice: /Stage[main]/Yum::Elff/Yum::Repo[elff]/Yumrepo[elff]/
failovermethod: failovermethod changed '' to 'priority'
info: changing mode of /etc/yum.repos.d/elff.repo from 600 to 644
notice: Finished catalog run in 8.10 seconds
notice: Caught INT; calling stop
[root@mon1a yum.repos.d]#
-----------------------------------------------
Do you need any further info?
Why does it happen in this case but not in simple case there only file
resources are involved?
Thanks
Alex
On Aug 29, 8:33 pm, Daniel Pittman <
dan...@puppetlabs.com> wrote: