大网数据广告活动
服务器运维问答

Puppet: ensure user is in wheel group on all nodes without affecting other group membership

· 52CE 我爱测

I want to make sure user bob is in wheel group on every server managed by puppet, but I do not want to change any other group membership for that user if on one node bob belongs to the apache group, and on another he is in sftpus…

问题原文

原帖链接 · usedTobeaMember · CC BY-SA 3.0

I want to make sure user bob is in wheel group on every server managed by puppet, but I do not want to change any other group membership for that user if on one node bob belongs to the apache group, and on another he is in sftpusers. I want to leave him in any group he belongs to, and additionally ensure he is in wheel.

What is the proper solution? It cannot be to exec => usermod or something tacky like that. There must be something better I imagine.

已采纳解答

原帖链接 · devicenull · CC BY-SA 4.0

If you're already having Puppet manage this user, you can just use the 'groups' attribute to determine what groups a user is in. If the user is in groups that aren't managed by puppet, you'd want to set membership to 'minimum', which would just ensure the user is in the specified groups (it wouldn't overwrite any existing groups).

For example:

user { "someuser":
    groups     => [ 'wheel', 'othergroup' ],
    membership => 'minimum',
}

This is explained a bit more in the type reference.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2014-03-16)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0 / CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。