[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設置