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

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

我有以下木偶食谱:

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

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

但依赖关系是“反转的”:用户依赖于组。这在创建资源时工作正常,但当我们想要删除时,关系应该是反转的。目前,用户资源将依赖于组,但无法删除组,因为用户将自己作为主组。哎呀...

确切的错误信息是:

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 删除用户和组?

答案1

首先尝试删除用户,然后在删除用户后才删除组。例如。

user {'pablo':
   ensure  =>  absent,
   }

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

相关内容