group资源
group的主要功能是管理系统组,包含组的名字、增/减组、组成员、组的gid等.
group { ‘资源标题‘: allowdupe ensure gid members name allowdupe provider }
allowdupe:是否允许系统存在同样的gid,false表示不允许设置相同的gid,true表示可以设置相同的gid.
ensure:创建或者删除,设置absent为删除组,设置present为创建组.
gid:设置组的gid,必须是数字,如果不指定,将自动分配,不同的系统自动分配的算法不一样,不推荐使用自动分配gid.
members:该组的成员.
name:该用户组的名字,默认与标题相同.
allowdupe:准许使用相同的gid,默认为false.
provider:支持的系统添加命令.
创建"meng"组的puppet代码:
[root@sh-web1 ~]# cat groupmeng.pp group {‘meng‘: ensure => present, gid => ‘701‘, }
运行结果:
[root@sh-web1 ~]# puppet apply groupmeng.pp Notice: Compiled catalog for sh-web1.localdomain in environment production in 0.06 seconds Notice: /Stage[main]/Main/Group[meng]/ensure: created Notice: Finished catalog run in 0.08 seconds
查看是否创建:
[root@sh-web1 ~]# cat /etc/group | grep meng meng:x:701:
删除"meng"组:
[root@sh-web1 ~]# puppet apply groupmeng.pp Notice: Compiled catalog for sh-web1.localdomain in environment production in 0.06 seconds Notice: /Stage[main]/Main/Group[meng]/ensure: removed Notice: Finished catalog run in 0.06 seconds [root@sh-web1 ~]# cat /etc/group | grep meng [root@sh-web1 ~]#
问题:members参数,puppet3.8 members参数配置不成功,做过的尝试?
1、member后面跟系统已存在的组,发现不行没成功,不存在的组也不成功,官网给的解释没怎么看懂?
官网链接:https://puppet.com/docs/puppet/5.2/types/group.html#group-attribute-members
members
The members of the group. For platforms or directory services where group membership is stored in the group objects, not the users. This parameter’s behavior can be configured with auth_membership.
members参数:组成员存储在某个平台或者目录服务的组对象中,需要参数auth_membership.
[root@sh-web1 ~]# cat groupmeng.pp group {‘meng‘: ensure => present, gid => ‘5560‘, auth_membership => yes, members => [‘wangwu‘,‘lisi‘], }
[root@sh-web1 ~]# puppet apply groupmeng.pp Notice: Compiled catalog for sh-web1.localdomain in environment production in 0.06 seconds Notice: /Stage[main]/Main/Group[meng]/ensure: created Notice: Finished catalog run in 0.05 seconds [root@sh-web1 ~]# cat /etc/group group group- [root@sh-web1 ~]# cat /etc/group | grep meng meng:x:5560:
本文出自 “青衫解衣” 博客,请务必保留此出处http://215687833.blog.51cto.com/6724358/1972900
原文地址:http://215687833.blog.51cto.com/6724358/1972900