我正在嘗試設置一個配置我的開發系統的手冊。我想將我的劇本「files」目錄中的/etc/hosts
文件複製到我係統上的/etc
目錄。目前,我做了以下內容:如何使用Ansible將文件複製到本地目錄?
# main.yml
- hosts: all
- tasks:
- copy: src=files/hosts
dest=/etc/hosts
owner=root
group=wheel
mode=0644
backup=true
become: true
# inventory
localhost ansible_connection=local
當我跑我得到這個錯誤的劇本:
fatal: [localhost]: FAILED! => {... "msg": Failed to get information on remote file (/etc/hosts): MODULE FAILURE"}
我相信這是因爲拷貝應該被使用將文件複製到遠程文件系統。那麼如何將文件複製到本地管理系統?我做了一個Google搜索,一切都在談論做前者。在Ansible文檔中我沒有看到這個問題。
「將文件複製到本地目錄」? 'scuse me,但是在什麼意義上是/ etc/hosts * local *? – Danimal
@Danimal:查看Dave的後續評論 **#inventory localhost ansible_connection = local ** 這意味着,他正在執行他在本地主機上的所有劇本資料 –