查看组内主机列表
ansible webservers --list-hosts
执行命令
- -m shell
- # ansible all -m shell -a hostname
复制文件
- -m copy
- # ansible all -m copy -a src=/etc/hosts dest=/etc/hosts
用户管理
-m user
添加用户
# ansible all -m user -a "name=lala password=123"
删除用户
# ansible web1 -m user -a "name=lala state=absent"
软件包管理
-m yum
删除软件
# ansible web1 -m yum -a name=httpd state=removed
安装软件
# ansible web1 -m yum -a name=httpd state=latest
服务管理
- -m service
- # ansible webservers -m service -a name=httpd state=started
采集主机信息
# ansible web1 -m setup -a
来源: http://www.bubuko.com/infodetail-2510407.html