On Apr 15, 8:04 pm, Sans <r.santanu....@gmail.com> wrote:
> On Apr 15, 9:37 am, Martijn Grendelman <mart...@iphion.nl> wrote
>
>
>
> > > On Apr 15, 9:12 am, Patrick <kc7...@gmail.com> wrote:
> > >> For the package example, I'd try "ensure => absent".  I think I remember 
> > >> that works.
>
> "ensure => absent" uses "rpm -e' to remove a package, which is a
> problem for the packages with related dependencies. Is there any way
> to use "yum remove" to do that? Cheers!!

You can use a conditional to make the package managed only when you
want to have it, and an exec to "yum remove" it when you don't:

if $i_want_httpd {
   package { "httpd":
       ...
   }
} else {
   exec { "yum -y remove httpd":
      onlyif => "rpm -q httpd"  # only if it's installed
   }
}

But that's messy, and it begs the question: if you have packages
installed that depend on httpd then don't you need to ensure them
absent anyway?  I mean, for each such package there are two
possibilities:

1) The dependent package is managed by Puppet.  In this case, you must
ensure it absent too, else you cannot achieve a consistent
configuration.  You will either get Puppet failures or flip-flops
between whether httpd is installed or not.  (I am fairly sure that
this is why the yum Package provider uses "rpm -e" instead of "yum
remove" in the first place.)  To fix it, you have to ensure the
dependent package absent too, and in that case you can address your
original problem by twiddling the dependent package's dependencies.
For example:

package { "httpd-special-gizmo":
   ...
   before => $i_want_httpd ? {
      "no" => Packge["httpd"],
      default => undef
   }
}

2) The dependent package is not managed by Puppet.  In this case,
think hard about why you want this situation in the first place.  If
you decide you do want it, then I would be very surprised if you
really also want to remove the dependent packages automatically.  If
you decide you do not want the situation, then you can convert this
case to case (1) by bringing the dependent packages under management.


John

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To post to this group, send email to puppet-users@googlegroups.com.
To unsubscribe from this group, send email to 
puppet-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/puppet-users?hl=en.

Reply via email to