2014-10-26 43 views
2

我在我的狀態文件中添加了以下邏輯,它在第一次安裝名爲agent的實用程序後基本上設置了新的穀物值。Salt States and grain values

{% if salt['grains.get']('agent') != 'installed' %} 
.............. 
agent_status: 
    grains.present: 
    - name: agent 
    - value: installed 

{% endif %} 

我第一次運行salt 'server1' state.highstate它返回以下這正是我期望:

---------- 
      ID: agent_status 
    Function: grains.present 
     Name: agent 
     Result: True 
    Comment: Set grain agent to installed 
    Started: 16:03:27.083578 
    Duration: 709.795 ms 
    Changes: 
       ---------- 
       agent: 
        installed 

當我隨後運行salt 'server1' state.highstate它返回:

server1: 
---------- 
      ID: states 
    Function: no.None 
     Result: False 
    Comment: No states found for this minion 
    Started: 
    Duration: 
    Changes: 

Summary 
------------ 
Succeeded: 0 
Failed: 1 

這是正確的行爲我有點困惑,因爲我預料到這不會表現爲失敗?此外,評論似乎在這裏有點誤導。

回答

1

是的,這是正確的行爲。發生什麼事情是鹽首先渲染了忍者。自從你第二次運行穀物時,你的小爪子會看到一個空的sls文件。因此,「發現這個馬仔無狀態」

編輯:如果你想避免讓「找到這個馬仔無狀態」的錯誤,你可以在底部添加一個無害的狀態,在神社外面這樣

/tmp/deletemeplease.txt: 
    file.absent 
+0

Arr - 我明白了。感謝您的迴應 – user1513388 2014-10-27 13:58:48