ansible批量自動化管理工具-file模組專題(五)
阿新 • • 發佈:2021-01-24
技術標籤:ansible
文章目錄
建立目錄,並設定許可權:(支援遞迴)
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’