Ansible (12) file module, ansible12file Module

Source: Internet
Author: User

Ansible (12) file module, ansible12file Module
File Module

Before the ansible command line, there was a copy module. In the era of playbook, there was also a module dedicated to copying files. Of course, this era is not just as simple as copying files.

Official explanations:

The file module contains the creation, copying, moving, and deletion operations of files, folders, and hyperlink classes.

Common Parameters
Parameter Name Required? Default Value Option Description
Follow No No Yes/no If the original file is a link, it is still a link after the copy.
Force No No Yes/no Enforced, not mentioned
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.
Path Yes Target path, which can also be replaced by dest and name
Src Yes The original location of the file/folder to be copied.
State No File File/link/directory/hard/touch/absent File indicates that a file is copied, link indicates that a soft link is finally made, directory indicates a folder, hard indicates a hard link, touch indicates that an empty file is generated, and absent indicates that a file is deleted.
Case
# Modify all groups, persons, and permissions of files. -File: path =/etc/foo. conf owner = foo group = foo mode = 0644 # operation link case-file: src =/file/to/link/to dest =/path/to/symlink owner = foo group = foo state = link # parameterized case-file: src =/tmp/{item. path} dest = {item. dest} state = link with_items:-{path: 'X', dest: 'y'}-{path: 'Z', dest: 'K'} # use touch to create an empty file and define the permission-file: path =/etc/foo. conf state = touch mode = "u = rw, g = r, o = r" # touch an empty file and modify the permission-file: path =/etc/foo. conf state = touch mode = "u + rw, g-wx, o-rwx"

How? Is it similar to copy?

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.