天天看點

Ansible檔案操作 file子產品(學習筆記三)

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子產品(學習筆記三)

3、建立空檔案:ansible all -m file -a "path=/root/testtouch.sh state=touch mode=0644"

Ansible檔案操作 file子產品(學習筆記三)

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

Ansible檔案操作 file子產品(學習筆記三)

5、删除目錄或檔案,強制執行:ansible all -m file -a "path=/root/testdirectory state=absent force=yes"

Ansible檔案操作 file子產品(學習筆記三)

繼續閱讀