2017-07-17 74 views
1

我使用Ansible自動執行某些網絡故障排除任務,但是當我嘗試ping我的所有設備作爲一個全面的檢查,我得到了以下錯誤:當我只有只讀訪問權時,如何使用Ansible?

"msg": "Authentication or permission failure. In some cases, you may have been able to authenticate and did not have permissions on the remote directory. Consider changing the remote temp path in ansible.cfg to a path rooted in \"/tmp\".

當我運行在Ansible詳細模式下命令吧這個錯誤之前,我得到以下輸出:

<10.25.100.1> EXEC /bin/sh -c '(umask 77 && mkdir -p " echo Cmd exec error./.ansible/tmp/ansible-tmp-1500330345.12-194265391907358 " && echo ansible-tmp-1500330345.12-194265391907358=" echo Cmd exec error./.ansible/tmp/ansible-tmp-1500330345.12-194265391907358 ") && sleep 0'

我是一個實習生,因此只具有隻讀訪問所有設備;因此,我認爲錯誤是由於mkdir命令而發生的。我的兩個問題是這樣的:

1)有沒有辦法將Ansible配置爲不在設備上創建任何臨時文件?

2)是否還有其他因素可能導致我錯過了這個錯誤?

我已經嘗試通過Ansible文檔搜索任何相關的配置,但是我沒有太多與Ansible合作的經驗,所以我一直無法找到任何東西。

回答

2

這個問題在更廣泛的背景下沒有意義。 Ansible是服務器配置自動化的工具。如果沒有寫入權限,則無法在目標機器上配置任何內容,因此Ansible沒有任何用例。

在一個狹義的上下文中,儘管您沒有發佈任何代碼,但您似乎試圖ping目標服務器。 Ansible ping module不是ICMP ping。相反,它是連接到目標服務器的組件,傳輸Python腳本並運行它們。腳本產生一個響應,這意味着目標系統滿足運行Ansible模塊的最低要求。

但是你似乎想將控制計算機上運行使用Ansible command module定期ping命令並檢查其狀態:

- hosts: localhost 
    vars: 
    target_host: 192.168.1.1 
    tasks: 
    - command: ping {{ target_host }} 

你可能想用failed_whenignore_errors,或changed_when參數玩。見Error handling in playbook

請注意,我建議在localhost上運行整個遊戲,因爲在您的配置中,配置目標計算機並不合適,因爲目標計算機在清單中的訪問權限有限。


此外:

Is there anyway to configure Ansible to not create any temp files on the devices?

是。通過raw module運行命令不會創建臨時文件。

你似乎有一個SSH訪問,你可以用它來運行一個命令,並檢查其結果是:

- hosts: 192.168.1.1 
    tasks: 
    - raw: echo Hello World 
     register: echo 
    - debug: 
     var: echo.stdout