1
我必須刪除某個目錄並在複製到遠程之前在本地創建它們。無論如何刪除和創建本地?如何刪除本地目錄
目前我使用「命令」
command: rm -r directory
但警告顯示爲
Consider using file module with state=absent rather than running rm
有沒有我們可以使用本地文件夾改變任何選項?
我必須刪除某個目錄並在複製到遠程之前在本地創建它們。無論如何刪除和創建本地?如何刪除本地目錄
目前我使用「命令」
command: rm -r directory
但警告顯示爲
Consider using file module with state=absent rather than running rm
有沒有我們可以使用本地文件夾改變任何選項?
您可以使用不同勢delegation methods或使用local_action
:
- local_action: file path=directory state=absent
如果你在劇本運行此,您可以使用使用本地連接,使該命令更改劇本的部分機器,然後將文件複製到遠程:
---
- hosts: 127.0.0.1
connection: local
tasks:
- name: Delete local directory
file: path=/directory state=absent
- hosts: myhosts
tasks:
copy: src=/directory dest=/foo/directory
我是否需要創建一個新的本地連接來更改本地文件? – Neil
這就是知道如何在遠程機器上本地運行它。您也可以使用local_action,如下所述。本地連接很好,如果你有一堆事情要做到本地。 –
謝謝@Scot Rankin – Neil