码迷,mamicode.com
首页 > 其他好文 > 详细

ansible之fetch模块

时间:2016-05-03 00:40:13      阅读:702      评论:0      收藏:0      [点我收藏+]

标签:ansible fetch模块拉取文件

fetch官方链接http://docs.ansible.com/ansible/fetch_module.html

文件拉取模块主要是将远程主机中的文件拷贝到本机中,和copy模块的作用刚刚相反,并且在保存的时候使用hostname来进行保存,当文件不存在的时候,会出现错误,除非设置了选项fail_on_missing为yes

fetch用法选项

[root@ansible ~]# ansible-doc -s fetch

less 436

Copyright (C) 1984-2009 Mark Nudelman


less comes with NO WARRANTY, to the extent permitted by law.

For information about the terms of redistribution,

see the file named README in the less distribution.

Homepage: http://www.greenwoodsoftware.com/less

- name: Fetches a file from remote nodes

  action: fetch

      dest=                  # A directory to save the file into. For example, if the `dest‘ directory is `/backup‘ a `src‘ file

                               named `/etc/profile‘ on host `host.example.com‘, would be saved

                               into `/backup/host.example.com/etc/profile‘

      fail_on_missing        # Makes it fails when the source file is missing.

      flat                   # Allows you to override the default behavior of appending hostname/path/to/file to the

                               destination.  If dest ends with ‘/‘, it will use the basename of

                               the source file, similar to the copy module. Obviously this is

                               only handy if the filenames are unique.

      src=\‘#\‘"                 # The file on the remote system to fetch. This `must‘ be a file, not a directory. Recursive

                               fetching may be supported in a later release.

      validate_checksum      # Verify that the source and destination checksums match after the files are fetched.



dest:用来存放文件的目录,例如存放目录为backup,源文件名称为/etc/profile在主机pythonserver中,那么保存为/backup/pythonserver/etc/profile


Fail_on_missing:当源文件不存在的时候,标识为失败


Flat:允许覆盖默认行为从hostname/path到/file的,如果dest以/结尾,它将使用源文件的基础名称


Src:在远程拉取的文件,并且必须是一个file,不能是目录


Validate_checksum:当文件fetch之后进行md5检查




示例如下


技术分享


本文出自 “村里的男孩” 博客,请务必保留此出处http://noodle.blog.51cto.com/2925423/1769542

ansible之fetch模块

标签:ansible fetch模块拉取文件

原文地址:http://noodle.blog.51cto.com/2925423/1769542

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!