1、以all主机组为目标执行id命令
[rhcsa@master zy1]$ ansible all -m command -a id
2、使用copy模块修改所有主机上的/etc/motd文件内容为welcome to ansible
[rhcsa@master zy1]$ ansible all -m copy -a ‘content=“welcome to ansible\n” dest=/etc/motd’
3、使用command模块查看/etc/motd文件的内容
[rhcsa@master zy1]$ ansible all -m command -a ‘cat /etc/motd’
4、使用user模块创建用户wukong,uid为2000
[rhcsa@master zy1]$ ansible all -m user -a ‘name=wukong uid=2000’
5、使用yum模块安装httpd软件包并使用service模块启动该服务
[rhcsa@master zy1]$ ansible all -m service -a ‘name=httpd state=started'