[admin@node1 ansible]$ ansible-doc -s group
- name: Add or remove groups
group:
gid: # Optional `GID' to set for the group.
name: # (required) Name of the group to manage.
state: # Whether the group should be present or not on the remote host.
system: # If `yes', indicates that the group created is a system group.
案例:
~~~
[admin@node1 ansible]$ ansible webserver -m group -a "name=hagroup gid=1052 state=present" -b --ask-sudo-pass
[DEPRECATION WARNING]: The sudo command line option has been deprecated in favor of the "become" command line arguments. This feature will be removed in version 2.6. Deprecation warnings can be disabled by
setting deprecation_warnings=False in ansible.cfg.
SUDO password:
192.168.20.131 | SUCCESS => {
"changed": true,
"gid": 1052,
"name": "hagroup",
"state": "present",
"system": false
}
192.168.20.132 | SUCCESS => {
"changed": true,
"gid": 1052,
"name": "hagroup",
"state": "present",
"system": false
}
~~~
删除组
~~~
[admin@node1 ansible]$ ansible webserver -m group -a "name=hagroup gid=1052 state=absent" -b --ask-sudo-pass
[DEPRECATION WARNING]: The sudo command line option has been deprecated in favor of the "become" command line arguments. This feature will be removed in version 2.6. Deprecation warnings can be disabled by
setting deprecation_warnings=False in ansible.cfg.
SUDO password:
192.168.20.131 | SUCCESS => {
"changed": true,
"name": "hagroup",
"state": "absent"
}
192.168.20.132 | SUCCESS => {
"changed": true,
"name": "hagroup",
"state": "absent"
}
~~~
- 第一章:Ansible基础入门
- 第二章:Ansible系列手册
- 第一节:Ansible系列之主机清单
- 第二节:Ansible系列之变量
- 第三节:Ansible系列之YAML
- 第四节:Ansible系列之条件判断
- 第五节:Ansible系列之循环
- 第六节: Ansible系列之tags
- 第七节:Ansible系列之Jinja2
- 第三章:Ansible系列之模块
- 第一节:user模块
- 第二节:group模块
- 第三节:cron模块
- 第四节:copy模块
- 第五节: file模块
- 第六节:yum模块
- 第七节:service模块
- 第八节:shell模块
- 第九节:script模块
- 第十节:setup模块
- 第十一节:filesystem和mount模块
- 第十二节:synchronize模块
- 第十三节: get_url模块
- 第十四节: package模块
- 第十五节:stat模块
- 第十六节:unarchive模块
- 第十七节: commang模块
- 第四章:Ansible-playbook介绍
- 第五章:Ansible系统环境
- 第一节:Ansible Role 系统环境之epel设置