Ansible () file module

Source: Internet
Author: User

File module

In the previous ansible command line when there is a copy module, in the era of playbook naturally also have a module dedicated to file copy, of course, it is not only a copy of the file so simple.

From the official explanation:

The file module contains the creation, copying, movement, and deletion of files, folders, and Hyperlink classes.

Common parameters
Name of parameter whether you must Default Value Options Description
Follow No No Yes/no If the original file is link, the copy is still link
Force No No Yes/no Forced execution, didn't see?
Group No Set a group to have file permissions for copying to a remote node
Mode No Equivalent to chmod, parameter can be "u+rwx or u=rw,g=r,o=r"
Owner No Set the file permissions that a user has copied to the remote node
Path Yes The target path can also be replaced with Dest,name
Src Yes The original location of the file/folder to be copied.
State No File File/link/directory/hard/touch/absent File represents a copy of the document, the link represents the end of a soft link; directory represents a folder; hard links; Touch represents an empty file; Absent represents the deletion.
Case
# Modify all groups, people, and permissions for a file. - file: path=/etc/foo. conf owner=foo group=foo mode=0644 # Action Link case- file: src=/file/to/link/to dest=/path/to/symlink owner=foo Group=foo State=link #参数化案例- file: src=/tmp/{{Item.path}} dest={{item.dest}} state=linkWith_items:-{ path: ' x ', dest: ' y ' }-{ path: ' z ', dest: ' K ' }# Use Touch to create an empty file and define permissions- file: path=/etc/fooconf state=touch mode="U=rw,g=r,o=r" # Touch an empty file, and modify permissions- file: path=/etc/fooconf state=touch mode="u+rw,g-wx,o-rwx" 

How is it? Is it similar to copy?

Ansible () file module

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.