Hi Nan
Adding
file { "/etc/yum.repos.d/${name}.repo":
ensure => file
}
took care of the problem.
I still wonder if it should have worked without explicit file
resource?
Or "purge" is not supposed to be aware of other non file puppet
resources?
Thanks
Alex
On Aug 30, 5:11 pm, Nan Liu <[email protected]> wrote:
> On Mon, Aug 29, 2011 at 7:38 PM, piavlo <[email protected]> wrote:
> > 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"]
> > }
>
> Not sure if this covers all the files in the yum.repos.d directory.
> You can try adding an additional file resource in the define resource
> to avoid the file directory purge performing any action on files
> created by yumrepo resource type:
>
> file { "/etc/yum.repos.d/${name}.repo":
> ensure => file,
>
> }
>
> Alternatively, I think yumrepo can be modeled as a file using a file
> using ERB template instead of yumrepo resource:
>
> define yum::repo {
> ...
>
> file { "/etc/yum.repos.d/${name}.repo":
> ensure => file,
> owner => 'root',
> group => 'root',
> mode => '0644',
> source => template('yum/yumrepo.erb')
> }
>
> }
>
> yumrepo.erb:
> [<%=name%>]
> name=<%=desc%>
> baseurl=<%=baseurl%>
> ...
>
> Thanks,
>
> Nan
--
You received this message because you are subscribed to the Google Groups
"Puppet Users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/puppet-users?hl=en.