ansible-file module

path parameters: parameter must be used to specify the action of a file or directory, in the previous version of ansible using dest parameter or name parameter specifies the file or directory to be operated, for compatibility with previous versions, you can also use the dest or name.

state parameter: This parameter is very flexible, it is necessary to set the corresponding value according to the situation. For example, we want to create / testdir / a / b directory on the remote host, you need to set path = / testdir / a / b, but we can not be seen from the "/ testdir / a / b" is the path b a file or a directory, ansible also not just from a string know you want to create a file or directory, so we need to be described by state parameters. When we want to create / testdir / a / b is a directory, you need to set the value of state for directory, "directory" is a directory of meaning, when it is combined with path, ansible will be able to know that our goal is to be operated a directory. Similarly, when we want to operate / testdir / a / b is a file, you need to set the value of state to touch. When we want to create a soft link files, you need the state to link. When you want to create a hard link files, you need to set the state hard. When we want to delete a file (do not distinguish between objective is to delete the file, directory, or link), you need to set the value of state is absent, "absent" for the absence of meaning, when we want to operate in absentia goal " ", it means that we want to remove the target.

src parameters: When state is set to link or hard, mean that we want to create a chain of soft or hard, so we have to specify which file soft or hard chain link, the link can be specified by the source parameter src.

force parameters: When state = link, and can be used with this parameter forces to create a link file when the force = yes, indicate force the creation of linked files. But forced to create a link file is divided into three cases. Case 1: When the link points to a file you want to create a source file does not exist, use this parameter, you can force the creation of a link file. Case 2: When you want to create a link file to a directory file and link files with the same name already exists, the force set to yes, the same file will be covered for the linked file, equivalent to delete the same file, create a link file. Case three: When you want to create a link to a file directory already exists a file with the same name as the linked file, and link file points to the source file does not exist, then is forced to replace the same file name as the linked files.

owner parameter: the operation for specifying the owner of the file, the user corresponding to the owner of the remote host must be present, otherwise error.

Parameters group: is a group of operations for designating the file, is a group corresponding to the group must exist in the remote host, or error.

mode parameter: used to specify whether the file being operated, for example, if you want to file permissions to "rw-rx ---", can be used to set mode = 650, or using mode = 0650, the effect is the same . If you want to set special permissions, such as setting suid binary file, you can use the mode = 4700.

recurse parameters: when the file is a directory to be operated, the recurse set to yes, attributes recursively modify files in the directory.

Guess you like

Origin www.cnblogs.com/weisunblog/p/12168413.html