1.创建目录
ansible update -m file -a 'path=/tmp/dd state=directory mode=0755'
2.修改文件属性
ansible update -m file -a 'path=/tmp/dd state=touch mode="u=rw,g=r,o=r"'
3.创建软连接
ansible update -m file -a 'src=/tmp/dd dest=/tmp/ddl owner=root group=root state=link force=yes'
4.修改拥有者
ansible update -m file -a 'path=/tmp/dd owner=tomcat group=root mode=0644'
5.创建用户
ansible update -m user -a 'name=johd' -become
6.删除用户
ansible update -m user -a 'name=johd state=absent' -become
7.创建秘钥
ansible update -m user -a 'name=johd generate_ssh_key=yes ssh_key_bits=2048' -become
8.创建组
ansible test -m group -a 'name=ansible state=present' -become
9.删除组
ansible update -m group -a 'name=pig state=absent' -become
10.下载文件的远程服务器
ansible update -m get_url -a 'url=http://www.baidu.com dest=/tmp/baidu.txt mode=0777'
11.增加一个cron任务
ansible update -m cron -a "backup=yes name='test cron' minute=*/2 hour=* job='ls /tmp >/dev/null'"
12.安装服务
ansible update -m yum -a 'name=httpd state=prestent' -become
13.停止httpd
ansible update -m service -a 'name=httpd state=stopped'
14.重启httpd
ansible update -m service -a 'name=httpd state=restarted'
15.修改sysctl文件
ansible update -m sysctl -a 'name=vm.overcommit_memory value=1' -become
16.挂载/dev/vda盘到/mnt/data目录
ansible update -m mount -a 'name=/mnt/data src=/dev/vda fstype=ext4 state=mounted'
17.远程查看内存
ansible Client -m command -a "free -m "
18.远程执行脚本
ansible Client -m script -a "/home/test.sh"
19.实现主控端向目标主机拷贝文件
ansible Client -m copy -a "src=/root/rcp dest=/backup/"
20.yum安装
ansible Client -m yum -a "name=htop state=latest"