file模块:修改文件属性、生成链接文件、创建空文件、创建空目录、删除目录文件

1、修改文件属性, ansible all -m file -a "path=/root/test.sh owner=test group=test mode=0644"

Ansible文件操作 file模块(学习笔记三)
image.png

2、生成链接文件:ansible all -m file -a "src=/root/test.sh dest=/root/testlink.sh owner=root group=root state=link"

Ansible文件操作 file模块(学习笔记三)
image.png

3、创建空文件:ansible all -m file -a "path=/root/testtouch.sh state=touch mode=0644"

Ansible文件操作 file模块(学习笔记三)
image.png

4、创建空目录: ansible all -m file -a "path=/root/testdirectory state=directory mode=0644"

Ansible文件操作 file模块(学习笔记三)
image.png

5、删除目录或文件,强制执行:ansible all -m file -a "path=/root/testdirectory state=absent force=yes"

Ansible文件操作 file模块(学习笔记三)
image.png

相关文章:

  • 2021-07-20
  • 2022-03-03
  • 2022-03-09
  • 2021-08-31
  • 2021-03-31
  • 2021-08-09
猜你喜欢
  • 2022-12-23
  • 2021-06-20
  • 2022-12-23
  • 2022-02-02
  • 2021-07-27
  • 2021-11-06
相关资源
相似解决方案