ansible批量自动化管理工具-file模块专题(五)

创建目录,并设置权限:(支持递归)

ansible all_remote -m file -a 'name=/tmp/dir1/test state=directory mode=0777'

删除目录:

ansible all_remote -m file -a 'name=/tmp/dir1 state=absent'

创建新文件:

 ansible all -m file -a 'name=/tmp/file.txt state=touch mode=0777'

删除文件:

 ansible all -m file -a 'name=/tmp/file.txt state=absent'

创建软连接:

ansible all_remote -m file -a 'src=/tmp dest=/home/wb-user/tmp.link state=link'
【参数】
目标: /tmp
软连接:/home/wb-user/tmp.link
意思: 访问/home/wb-user/tmp.link直接跳转到/tmp目录下

在这里插入图片描述

删除软连接:

ansible all -m file -a 'dest=/home/wb-user/tmp.link state=absent'

创建文件指定所有者,权限:

ansible all -m file -a ‘path=/root/a.sh owner=liych mode=755’

猜你喜欢

转载自blog.csdn.net/weixin_43010385/article/details/113062562
今日推荐