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. PS 如何制作环绕文字效果

    最终效果 地球素材 1.打开素材,使用椭圆选区工具按住shift绘制正圆选区 2.转到路径面板,将选区变为工作路径 3.选择文字工具,在路径上输入文字 4.ctrl+T,按住ctrl+alt,鼠标拖动 ...

  2. 显式启动Activity和隐式启动Activity

    1.显式启动Intent intent = new Intent(this, class);startActivity(intent); 2.隐式启动AndroidManifest.xml中定义某个A ...

  3. 工业控制系统USB存储设备可信管理方案的(ICICS2015)论文PPT:TMSUI: A Trust Management Scheme

    本PPT是发表在ICICS2015 大会的论文 TMSUI: A Trust Management Scheme of USB Storage Devices for Industrial Contr ...

  4. 【Excle数据透视表】如何调整压缩形式显示下的缩进字符数

    调整前:                                                                                                 ...

  5. 【BIEE】分析的解析机制

    今天使用BIEE时意外的发现个问题,BIEE在展示结果时候,是先进行排序,然后再展示.具体测试案例如下: 首先,存在如下数据: 在BIEE展示效果如下: 目前是根据O1,02,03,04,05,06, ...

  6. 网站拓扑图(来自qq)

  7. 关于Android项目中的分层,参考eoecn开源项目(8.29)

    以下为eoecn开源项目的分层情况: ├ cn.eoe.app --存放程序全局性类的包├ cn.eoe.app.adapter --存放适配器的实现类的包 ├ cn.eoe.app.adapter. ...

  8. WAS集群系列(3):集群搭建:步骤1:准备文件

    说明:"指示轨迹"为"点选顺序",截图为点击后效果截图 环境 项目点 指标 WAS版本号 7.0 操作系统 Windows 2008 系统位数 64bit 内存 ...

  9. Python基础之模块2

    如何导入多个模块? import re #单行导入多个模块 '''多行导入多个模块''' import re import sys import os 如何给模块起别名? import my_modu ...

  10. Android SDK环境搭建

    方法有二 方法一: Android SDK开发包国内下载地址 http://www.cnblogs.com/bjzhanghao/archive/2012/11/14/android-platform ...