3
我最近開始在我們的實驗室中使用Salt進行一些自動化操作。 我一直在嘗試測試自定義狀態,我可以自己寫。 我創建具有以下功能的簡單的測試:SaltStack,無法運行自定義狀態模塊
def write_text(text, where):
ret = {'text': text, 'where': where, 'result': False}
try:
with open(r''+where, 'w') as file:
file.write('this is a test')
ret['result'] = True
except:
ret['result'] = False
return ret
我放置在該文件中/srv/salt/_states/my_test.py
我還創建了一個SLS文件在/ SRV /鹽/ my_test .sls
#Test custom state module
custom_state_test:
my_test:
- write_text
- text: 'this is a test'
- where: 'C:\text.txt'
但每當我使用奴才運行此salt win64-minion1 state.sls my_test
(我的手下是Windows機器),我收到以下錯誤
win64-minion1:
----------
ID: custom_state_test
Function: my_test.write_text
Result: False
Comment: State 'my_test.write_text' was not found in SLS 'my_test'
Reason: 'my_test.write_text' is not available.
Started:
Duration:
Changes:
我遵循SaltStacks文檔中的指南,但仍然無法弄清楚什麼是錯的。
你是否嘗試過:'salt'*'saltutil.sync_states' – tudoricc
是的,我做了,沒有幫助。 –
您可以隨時爲master/minion啓用debug log_level並查看它是否找到您的文件。 –