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