1、以all主机组为目标执行id命令
[admin@sunhailang ~]$ mkdir test01
[admin@sunhailang ~]$ cd test01
[admin@sunhailang test01]$ vim ansible.cfg
[admin@sunhailang test01]$ vim inventory
[admin@sunhailang test01]$ ansible all -m command -a 'id'
2、使用copy模块修改所有主机上的/etc/motd文件内容为welcome to ansible
[admin@sunhailang test01]$ ansible all -m copy -a 'content="welcome to ansible" dest=/etc/motd'
3、使用command模块查看/etc/motd文件的内容
ansible all -m command -a 'cat /etc/motd'
4、使用user模块创建用户wukong,uid为2000
[admin@sunhailang test01]$ ansible all -m user -a 'name=wukong uid=2000 state=present'
5、使用yum模块安装httpd软件包并使用service模块启动该服务
[admin@sunhailang test01]$ ansible all -m yum -a 'name=httpd'
admin@sunhailang test01]$ ansible all -m service -a 'name=httpd state=started'