Ansible series (9) Copy module, ansiblecopy

Source: Internet
Author: User

Ansible series (9) Copy module, ansiblecopy
Copy Module

The role of the copy module in ansible is to copy the files on the ansible Execution Machine to a remote node.
The opposite operation of the fetch module.

Common module Parameters
Parameter Name Required? Default Value Option Description
Src No The absolute path is used to locate the files on the machine where ansible runs. If a folder is copied, the folder will be copied as a whole. If the end is "/", only the contents in the folder will be taken into consideration. Everything feels like rsync
Content No It is used to replace src and copy the content of a specified file to a remote file.
Dest Yes Used to locate files on a remote node. An absolute path is required. If src points to a folder, this parameter must also point to a folder.
Backup No No Yes/no Back up the original file on the remote node before copying it. In case of any exceptions, the original file can be used.
Directory_mode No This parameter can only be used to copy folders. After this setting, new files in the folder will be copied. Old Ones won't be copied.
Follow No No Yes/no If a link exists in the copied folder, the link will be copied.
Force No Yes Yes/no The default value is yes, which overwrites files with different remote content (the file name may be the same ). If no, the file will not be copied. If this file is available remotely
Group No Sets the permission for a group to copy files to a remote node.
Mode No Equivalent to chmod, the parameter can be "u + rwx or u = rw, g = r, o = r"
Owner No Sets the permission for a user to copy files to a remote node.
Case
# Set/srv/myfiles/foo. copy the conf file to the remote node/etc/foo. conf, whose owner is foo, whose group is foo, and whose permission is 0644-copy: src =/srv/myfiles/foo. conf dest =/etc/foo. conf owner = foo group = foo mode = 0644 # the same as in the preceding case, the difference is just permission writing-copy: src =/srv/myfiles/foo. conf dest =/etc/foo. conf owner = foo group = foo mode = "u = rw, g = r, o = r" # Write another permission-copy: src =/srv/myfiles/foo. conf dest =/etc/foo. conf owner = foo group = foo mode = "u + rw, g-wx, o-rwx" # copy/mine/ntp. conf to remote section And back up/etc/ntp. conf on the remote node. -Copy: src =/mine/ntp. conf dest =/etc/ntp. conf owner = root group = root mode = 644 backup = yes
Common parameter return values
Parameter Name Parameter description Return Value Return Value Type Example
Src Location on ansible executor Changed String /Home/httpd/. ansible/tmp/ansible-tmp-1423796390.97-147729857856000/source
Backup_file Back up the original file Changed and if backup = yes String /Path/to/file.txt. 2015-02-12 @ 22:09 ~
Uid After execution, the owner's ID Success Int 100
Dest Target directory or file of the remote node Success String /Path/to/file.txt
Checksum The checksum value after the file is copied. Success String 6e642bb8dd5c2e027bf21dd923337cbb4214f827
Md5sum Md5 checksum value after the file is copied When supported String 2a5aeecc61dc98c4d780b14b330e3282
State Status after execution Success String File
Gid Group ID with folders and files after execution Success Int 100
Mode Permission for the file after execution Success String 0644
Owner Name of the file owner after execution Success String Httpd
Group Names of all groups in the file after execution Success String Httpd
Size File size after execution Success Int 1220

I have a lot of modules today. Do you understand? There will be a simple case next time.

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.