Ansible常用模块用法 file 模块

File 模块
功能:设置文件属性
1.###创建文件与删除文件
path:为路径
state:可以理解处理动作配合path这个参数使用。

ansible webservers -m file -a 'path=/data/file.log state=touch'


###创建文件并更改文件的所有者 所属组 以及文件权限<可用 owner group mode 等参数进行修改>

ansible webservers -m file -a 'path=/data/file.log state=touch owner=cql group=cql mode=666 '

 

 

 

 

 

 

2.###删除文件(也可删除目录)

ansible webservers -m file -a 'path=/data/file.log state=absent'

3.###创建软连接文件

ansible webservers -m file -a 'src=/etc path=/data/etc-link state=link'

 

 

 
4.###创建目录,创建目录时也可通过<owner group mode 来修改权限>

ansible webservers -m file -a 'path=/data/directory state=directory

 

 



 

 

 

 

 

 

posted on 2021-05-29 19:30  1251618589  阅读(4)  评论(0)    收藏  举报

导航