#帮助
ansible-doc user
#创建用户
ansible webserver -m user -a 'name=pengge state=present'#将密码加密echo'512050951'| openssl passwd -1 -stdin
#修改密码
ansible webserver -m user -a 'name=qianfeng password="$1$XVzsJMDr$5wI4oUaQ.emxap6s.N272."'#修改shell
ansible webserver -m user -a 'name=qianfeng shell=/sbin/nologin append=yes'#删除用户
ansible webserver -m user -a 'name=qianfeng state=absent'
yum模块
#帮助
ansible-doc yum
#升级host1所有包
ansible host1 -m yum -a 'name="*" state=latest'#host2安装http
ansible host2 -m yum -a 'name="httpd" state=latest'
服务模块
#帮助
ansible-doc service
#启动httpd
ansible host2 -m service -a 'name=httpd state=started'#开机启动httpd
ansible host2 -m service -a 'name=httpd state=started enabled=yes'#停止httpd
ansible host2 -m service -a 'name=httpd state=stopped'#重启httpd
ansible host2 -m service -a 'name=httpd state=restarted'#开机禁止启动
ansible host2 -m service -a 'name=httpd state=started enabled=no'
file模块
#帮助
ansible-doc file
#在host1创建路径为/tmp/1.txt,并且赋予777权限的文件
ansible host1 -m file -a 'path=/tmp/1.txt mode=777 state=touch'#在host1创建在/tmp/下的目录catalog,并赋予777权限
ansible host -m file -a 'path=/tmp/catalog mode=777 state=touch'