Re: [Puppet Users] delete home directory rescurively

923 views
Skip to first unread message

Moses Mendoza

unread,
Nov 25, 2012, 1:39:28 PM11/25/12
to puppet...@googlegroups.com
On Sat, Nov 24, 2012 at 8:28 AM, bluethundr <dunp...@gmail.com> wrote:
> Is there a way using puppet to delete the home directories recursively of
> employees who have left the company?

Are your users managed by Puppet? If so, perhaps check out
`managehome` of the user type.
http://docs.puppetlabs.com/references/latest/type.html#user .
Depending on the capabilities of the provider for your system, setting
`managehome => true` will create/remove user home directories.

>
> So far I've tried:
>
> file { "/export/home/user":
> name => "$home_dir/user",
> ensure => 'absent'
> }
>
> I also tried
>
>
>
> file{'export/home/user':
> name => "$home_dir/user",
> purge => true,
> recurse => true,
> force => true,
> backup => false,
> }
>
> But neither worked. Is there a way to do this with puppet currently? All I
> could find in the googlesphere was how to create directories (and keep them
> clean) with puppet but not how to destroy them. Perhaps this would be TOO
> destructive a power for puppet to wield?
>
> Thanks
> Tim
>
> --
> 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/-/ffzGcfykLHIJ.
> To post to this group, send email to puppet...@googlegroups.com.
> To unsubscribe from this group, send email to
> puppet-users...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/puppet-users?hl=en.

jcbollinger

unread,
Nov 26, 2012, 1:49:21 PM11/26/12
to puppet...@googlegroups.com


On Saturday, November 24, 2012 10:28:44 AM UTC-6, bluethundr wrote:
Is there a way using puppet to delete the home directories recursively of employees who have left the company?

So far I've tried:

   file { "/export/home/user":
        name => "$home_dir/user",
        ensure => 'absent'
      }

I also tried

 
file{'export/home/user':
  name => "$home_dir/user",
  purge => true,
  recurse => true,
  force => true,
  backup => false,
}

But neither worked. Is there a way to do this with puppet currently?


If you don't want to or can't do this via User resources, then it ought to work to add "ensure => absent" in your second version.

Alternatively, you can always resort to

exec { "Remove ${user}'s Home":
  command => "/bin/rm -rf ${home_dir}/${user}",
  onlyif => "/usr/bin/test -e ${home_dir}/${user}"
}


John

Eduardo A Muñoz

unread,
Nov 26, 2012, 1:51:47 PM11/26/12
to puppet...@googlegroups.com
tidy puppet type works recursively too.

--
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/-/dDIVaCy8uOQJ.

To post to this group, send email to puppet...@googlegroups.com.
To unsubscribe from this group, send email to puppet-users...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.



--
Eduardo A. Muñoz
GPG Key fingerprint = 175E 6AEB AD23 8EFE 0FC3 F558 9AB1 7885 40A4 ABBB
CCNA - CCNP
Reply all
Reply to author
Forward
0 new messages