On Friday, October 5, 2012 12:40:07 PM UTC-5, eduardo wrote:
>
> Hi all, 
> I wondering why having provider=useradd the parameter managehome => 
> true don't delete home directory ? 
>  I have : 
> user { $name: ensure => absent, managehome => true } 
> As result, home directory was not deleted. 
>
> I appreciate any advise about it. 
> Thanks in advanced, eduardo 
>


It is reasonably common to want to create home directories automatically 
when creating a user account, but at least as common to want to *avoid*removing 
them when removing a user.  I see that the type reference appears 
to suggest that "managehome => true" would produce both behaviors, but that 
is not consistent with historic Puppet behavior, which is to provide only 
homedir creation, not removal.  I don't know whether the docs are 
misleading, whether Puppet is buggy in this regard, or whether you're using 
a different version than is described by the current docs.

If you want to work around this issue, you can wrap your User declarations 
in a defined type that provides the desired behavior.  A minimalistic 
version might look something like this:

modules/user/manifests/hosted_user.pp:
----------------------------------------------------------
define user::hosted_user ($ensure = 'present') {
  $homedir = "/home/${name}"

  user { "${name}":
    ensure => "${ensure}",
    home => "${homedir}",
    managehome => true
  }

  if "${ensure}" == 'absent' {
    file { "${homedir}":
      ensure => absent,
      recurse => true,
      require => User["${name}"]
    }
  }
}
------

You could then use it like so:

user::hosted_user { 'eduardo': ensure => absent }

For real-world use you would probably want additional parameters, etc.


John

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/puppet-users/-/4ideXPg-0SAJ.
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