ansible files Module:fetch & copy & Template.....continuing

Source: Internet
Author: User

The fetch module is the same as the copy function, which is the file transfer between different machines, the former is pulling files from the node to the master machine (the machine with ansible), the latter is transferring files from the master to the node. The template module can insert variables into the copied file.

(Official document) the Copy module copies a file on the local box to remote locations. Use the Fetch module to copy files from remote locations to the local box. If you need variable interpolation with copied files, use the template module.

Common parameters:

SRC and dest are abbreviations for source and destination, ignoring.

Fail_on_missing=yes, if the source file does not exist, the task will fail.

The following command line illustrates:

1, #ansible hostname-m fetch-a "Src=/tmp/srcfile dest=/tmp/destdir"

Regardless of whether dest ends with "/", the path to the target file on the master machine is:/tmp/destdir/hostname/tmp/srcfile


2, #ansible hostname-m fetch-a "Src=/tmp/srcfile dest=/tmp/destdir/ Flag=yes"

Path to the destination file on the master:/tmp/destdir/srcfile

Run the operation on my own the following will be an error

#ansible hostname-m fetch-a "Src=/tmp/srcfile dest=/tmp/destdir flag=yes"

#ansible hostname-m fetch-a "src=/tmp/* dest=/tmp/destdir/flag=yes" I thought the files in the Src/tmp directory would be copied to the/tmp/destdir directory.


3, #ansible hostname-m fetch-a "Src=/tmp/srcfile dest=/tmp/destdir/12345 flag=yes"

The path to the destination file on the host computer:/tmp/destdir/12345 actually renamed the file (there was no Destdir directory on the console)


4, #ansible hostname-m fetch-a "Src=/tmp/srcfile dest=destdir/12345 flag=yes"

Path of the destination file on the master:/etc/ansible/destdir/12345 (relative to ansible master path)

This article is from the "11524698" blog, please be sure to keep this source http://11534698.blog.51cto.com/11524698/1826465

ansible files Module:fetch & copy & Template.....continuing

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.