Ansible中的同步模块(rsync)

Synchronize模块

1
2
3
4
5
6
7
  This is a wrapper around rsync. Of course you could just use the
  command action to call rsync yourself, but you also have to add a
  fair number of boilerplate options and host facts. You still may
  need to call rsync directly via `command' or `shell' depending on
  your use case. The synchronize action is meant to do common things
  with `rsync' easily. It does not provide access to the full power of
  rsync, but does make most invocations easier to follow.

这是一个关于rsync的模块。

参数

必填

默认值

选项

说明

archive

no

yes

yes

no

显示rsync的存档标志所属信息

checksum

no

no

yes

no

校验

compress

no

yes

yes

no

在传送过程中压缩文件数据

dest

yes

   

目标路径,路径可以绝对或相对

delete

no

no

yes

no

删除srv中不存在的文件

copy_links

no

no

yes

no

复制符号链接,是映射的文件复制

dest_port

no

22

yes

no

目标主机端口号(ansible_ssh_port优先于此值)

group

no

存档选项值

yes

no

保留文件的所属组

owner

no

存档选项值

yes

no

保留文件的所属者(只有超级用户可以操作)

perms

no

存档选项值

yes

no

保留文件的权限

rsync_opts

no

no

 

通过此选项指定其他的rsync的选项

rsync_path

no

   

指定rsync命令到远程主机上运行

rsync_timeout

no

0

 

指定rsync的timeout时间以秒为单位

src

yes

   

源地址(路径可以是绝对或相对的)

times

no

存档选项值

yes

no

保留文件的修改时间

exclude-from

no

no

yes

no

用于定义排除多个文件夹和文件

exclude

no

no

yes

no

用于定义排除单独的文件夹和文件

实例展示:

1
2
3
4
5
6
---
- hosts: web
  remote_user: deploy
  tasks:
    - name: webserver update web server (--exclude-file)
      synchronize: src=/home/deploy/webserver/  dest=/data/web/webserver/ rsync_opts=--delete,--exclude-from=/data/ansible/public/excludefile

实际使用:比用copy模块速度增加很多

cat stbverify_update.yml 
---
- name: handlers adserver
hosts: adservers
user: root
tasks:
- name: copy file
synchronize: src=/etc/ansible/STBVerify dest=/root/ rsync_opts=--delete 
notify: stbverify handlers
handlers:
- name: stbverify handlers
shell: /bin/bash /data/sh/stbverify_update.sh

原文:https://www.cnblogs.com/weifeng1463/p/8484316.html

ansible进阶:https://www.ibm.com/developerworks/cn/linux/1608_lih_ansible/index.html

ansible copy文件比较慢, 使用Synchronize模块的更多相关文章

  1. ansible笔记(4):常用模块之文件操作

    前文中,我们已经介绍了怎样使用模块,而且我们知道,ansible有很多模块,每个模块都有自己的功能,"模块"涉及到的方向比较多,所以对于个人来说,并没有必要了解所有的模块,我们只需 ...

  2. Ansible系列(二):选项和常用模块

    html { font-family: sans-serif } body { margin: 0 } article,aside,details,figcaption,figure,footer,h ...

  3. synchronize模块

    synchronize模块 使用rsync同步文件,其参数如下: archive: 归档,相当于同时开启recursive(递归).links.perms.times.owner.group.-D选项 ...

  4. Ansible自动化搭建及工具集和常见模块、命令详情(重点)

    一.ansible介绍 1.ansible简介 官方的title是“Ansible is Simple IT Automation”——简单的自动化IT工具. Ansible跟其他IT自动化技术的区别 ...

  5. Ansible自动化运维工具及其常用模块

    Ansible自动化运维工具及其常用模块 目录 Ansible自动化运维工具及其常用模块 一.Ansible简介 1. Ansible概述 2. Ansible作用 3. Ansible的工作模块 4 ...

  6. shutil模块(高级的文件、文件夹、压缩包处理模块)

    shutil 模块 高级的 文件.文件夹.压缩包 处理模块 shutil.copyfileobj(fsrc, fdst[, length])将文件内容拷贝到另一个文件中 import shutil s ...

  7. shutil 模块 高级的文件、文件夹、压缩包 处理模块

    高级的文件.文件夹.压缩包 处理模块 # 将文件内容拷贝到另一个文件中 shutil.copyfileobj(fsrc, fdst[, length]) import shutil shutil.co ...

  8. shutil——高级的 文件、文件夹、压缩包 处理模块

    高级的 文件.文件夹.压缩包 处理模块 shutil.copyfileobj(fsrc, fdst[, length])复制文件内容(不包含元数据)从类文件对象src到类文件对dst.可选参数leng ...

  9. Cocos2d-x建工程时避免copy文件夹和库

    方法一:(官方做法) 打开F:\cocos2d-1.0.1-x-0.9.1目录下的cocos2d-win32.vc2010.sln文件,然后右键点击解决方案,选择"添加"—&quo ...

随机推荐

  1. How to Start a New Cocos2d-x Game for version 3.0

    This documentation will show you how to use cocos console to create and run a new project. Runtime R ...

  2. 隐藏ion-nav-back-button的文字

    <ion-nav-bar class="bar-positive"> <ion-nav-back-button> </ion-nav-back-but ...

  3. C# const和static readonly区别

    [转]C# const和static readonly区别 以前只是知道Const和static readonlyd的区别在于const的值是在编译期间确定的,而static readonly是在运行 ...

  4. different between method and function

    A method is on an object. A function is independent of an object. For Java, there are only methods. ...

  5. ubuntu 14.04 anaconda安装

    Python的准备工作 Python 一个备受欢迎的点是社区支持很多,有非常多优秀的库或者模块.但是某些库之间有时候也存在依赖,所以要安装这些库也是挺繁琐的过程.但总有人忍受不了这种 繁琐,都会开发出 ...

  6. 网络相关系列之四:数据解析之SAX方式解析XML数据

    一.XML和Json数据的引入: 通常情况下.每一个须要訪问网络的应用程序都会有一个自己的server.我们能够向server提交数据,也能够从server获取数据.只是这个时候就有一个问题,这些数据 ...

  7. JavaFX打包到Android上

    让JavaFX执行到移动平台一直是社区努力完毕的事.  当然,眼下已经能够让JavaFX执行到Android和IOS平台了,以下我们来看看怎样打包自己的JavaFX项目到Android平台.  首先下 ...

  8. 求重集的r-组合

    具体的就不在这里说了,如果有兴趣的可以把我的工程包下载下来看,留个URL http://pan.baidu.com/s/1bnes1HX

  9. iOS8的autolayout和size class

    前一阵子看到几篇不错的布局教程,Mark下. 初探iOS8中的size class 自适应布局(Adaptive Layout)教程1 自适应布局(Adaptive Layout)教程2 为iPhon ...

  10. php7.0 出现 curl_setopt(): Disabling safe uploads is no longer supported in 报错!

    项目换成php7.0,进行了测试,使用curl时,出现: curl_setopt(): Disabling safe uploads is no longer supported in xxx.定位到 ...