|
ansible group模块与系统命令使用相似
参数 | 是否必要
| 默认 | 选项 | 说明 | gid | no |
|
| 选择需要设置的GID | name | yes |
|
| 需要配置的组名 | state | no | present | present
absent
| 添加或删除组 | system | no | no | yes
no
| yes时添加的是系统组 |
1
2
3
4
5
6
7
8
| # ansible dbserver -m group -a "name=zld state=present"
172.16.110.49 | SUCCESS => {
"changed": true,
"gid": 1001,
"name": "zld",
"state": "present",
"system": false
}
|
1
2
3
| # ansible dbserver -a "grep zld /etc/group"
172.16.110.49 | SUCCESS | rc=0 >>
zld:x:1001:
|
2.删除组
1
2
3
4
5
6
| # ansible dbserver -m group -a "name=zld state=absent"
172.16.110.49 | SUCCESS => {
"changed": true,
"name": "zld",
"state": "absent"
}
|
1
2
| # ansible dbserver -a "grep zld /etc/group"
172.16.110.49 | FAILED | rc=1 >>
|
3.添加系统组
1
2
3
4
5
6
7
8
| # ansible dbserver -m group -a "name=cklser state=present system=yes"
172.16.110.49 | SUCCESS => {
"changed": true,
"gid": 993,
"name": "cklser",
"state": "present",
"system": true
}
|
1
2
3
| # ansible dbserver -a "grep cklser /etc/group"
172.16.110.49 | SUCCESS | rc=0 >>
cklser:x:993:
|
系统组ID在1000以下
|
|
|