当另一个用户的主要群组使用puppet时如何删除群组

我有以下Puppet配方:

group{'pablo': ensure => absent, gid => 1020, } user{'pablo': ensure => absent, gid => 1020, managehome => false, } 

但是依赖关系是“颠倒的”:用户依赖于组。 这在创build资源时工作正常,但是当我们想要删除时,关系应该是相反的。 目前,用户资源依赖于组,但由于用户本身为主组,所以不能删除组。 糟糕!

确切的错误信息是:

 Error: Could not delete group pablo: Execution of '/usr/sbin/groupdel pablo' returned 8: groupdel: cannot remove the primary group of user 'pablo' Error: /Stage[main]/Seevibes::Admins/Seevibes::User[pablo]/Group[pablo]/ensure: change from present to absent failed: Could not delete group pablo: Execution of '/usr/sbin/groupdel pablo' returned 8: groupdel: cannot remove the primary group of user 'pablo' Error: Could not delete group pablo: Execution of '/usr/sbin/groupdel pablo' returned 8: groupdel: cannot remove the primary group of user 'pablo' Error: /Stage[main]/Seevibes::Admins/Seevibes::User[pablo]/Group[pablo]/ensure: change from present to absent failed: Could not delete group pablo: Execution of '/usr/sbin/groupdel pablo' returned 8: groupdel: cannot remove the primary group of user 'pablo' Notice: /User[pablo]: Dependency Group[pablo] has failures: true Warning: /User[pablo]: Skipping because of failed dependencies 

如何删除使用Puppet的用户和组?

尝试删除用户,然后只删除用户已经删除组。 例如。

 user {'pablo': ensure => absent, } group {'pablo': ensure => absent, require => User['pablo'], }