加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

ansible 常用模块总结

发布时间:2020-12-16 01:38:51 所属栏目:安全 来源:网络整理
导读:记录常用的模块功能,详细使用查看官网。 1. file模块 创建软连接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 " ? ?2.?synchronize模块 synchronize模块

  记录常用的模块功能,详细使用查看官网。

1. file模块

创建软连接
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"

?

?2.?synchronize模块

synchronize模块封装rsync,传输文件比copy模块速度快
ansible test  -m synchronize -a "src=/data/conf   dest=/data rsync_opts="--delete,--exclude=.git""

rsync_opts: 指定额外的rsync 参数

?

3. yum模块

ansible  test  -m yum -a "name=nginx"

?

4.?script模块

在远程服务器执行本地脚本
ansible test -m script -a  "time.sh"

?

5.shell模块

# 在远程服务器执行shell命令,万能模块
ansible test -m shell -a ‘hostname

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读