记录经常使用的模块功能,详细使用查看官网。nginx
建立软链接 ansible test -m file -a "src=/tmp/conf.d dest=/tmp/conf.d state=link" 删除目录 ansible test -m file -a "path=/tmp/test.conf state=absent"
synchronize模块封装rsync,传输文件比copy模块速度快 ansible test -m synchronize -a "src=/data/conf dest=/data rsync_opts="--delete,--exclude=.git"" rsync_opts: 指定额外的rsync 参数
ansible test -m yum -a "name=nginx"
在远程服务器执行本地脚本 ansible test -m script -a "time.sh"
# 在远程服务器执行shell命令,万能模块 ansible test -m shell -a 'hostname'