实例学习ansible系列(8)常用模块之user/group
2016-07-30 22:20
1096 查看
知识点:user模块,用于管理用户。
知识点:group模块,用于管理group。
知识点:group模块,用于管理group。
使用user模块添加用户
[root@host31 ~]# ansible host32 -m command -a "id test01" host32 | FAILED | rc=1 >> id: test01: no such user [root@host31 ~]# ansible host32 -m user -a "name=test01 group=root" host32 | SUCCESS => { "changed": true, "comment": "", "createhome": true, "group": 0, "home": "/home/test01", "name": "test01", "shell": "/bin/bash", "state": "present", "system": false, "uid": 1001 } [root@host31 ~]# ansible host32 -m command -a "id test01" host32 | SUCCESS | rc=0 >> uid=1001(test01) gid=0(root) groups=0(root) [root@host31 ~]#
使用user模块删除用户
[root@host31 ~]# ansible host32 -m user -a "name=test01 state=absent remove=yes" host32 | SUCCESS => { "changed": true, "force": false, "name": "test01", "remove": true, "state": "absent" } [root@host31 ~]# ansible host32 -m command -a "id test01" host32 | FAILED | rc=1 >> id: test01: no such user [root@host31 ~]#
使用group 模块添加group
[root@host31 ~]# ansible host32 -m shell -a "cat /etc/group |grep testgrp01" host32 | FAILED | rc=1 >> [root@host31 ~]# ansible host32 -m group -a "name=testgrp01" host32 | SUCCESS => { "changed": true, "gid": 1001, "name": "testgrp01", "state": "present", "system": false } [root@host31 ~]# ansible host32 -m shell -a "cat /etc/group |grep testgrp01" host32 | SUCCESS | rc=0 >> testgrp01:x:1001: [root@host31 ~]#
使用group模块删除group
[root@host31 ~]# ansible host32 -m group -a "name=testgrp01 state=absent" host32 | SUCCESS => { "changed": true, "name": "testgrp01", "state": "absent" } [root@host31 ~]# ansible host32 -m shell -a "cat /etc/group |grep testgrp01" host32 | FAILED | rc=1 >> [root@host31 ~]#
相关文章推荐
- 实例学习ansible系列(9)常用模块之yum/service
- 实例学习ansible系列(7)常用模块之ping/setup
- 实例学习ansible系列(12)常用模块之docker
- 实例学习ansible系列(10)常用模块之script
- 实例学习ansible系列(5)常用模块之copy
- 实例学习ansible系列(11)常用模块之get_url/cron/synchronize
- 实例学习ansible系列(4)常用模块之command/shell/raw
- 实例学习ansible系列(3)Ansible执行命令常用Option
- ansible学习系列2-ansible常用模块使用
- Ansible系列(二):选项和常用模块
- 实例学习ansible系列(15)playbook的条件和循环
- 实例学习ansible系列(13)第一个playbook
- jsp常用功能模块-JSP实例学习教程
- ansible常用模块实例
- java分布式系统部署学习(七)ansible 常用模块
- jsp常用功能模块-JSP实例学习教程
- 实例学习ansible系列(2)从Helloworld深度解析Ansible执行原理
- jsp常用功能模块-JSP实例学习教程
- ansible基础学习,常用模块概述
- 【Ansible学习】- 常用文件操作模块之copy模块