Cause of KeyError: '_errors' when running salt state.highstate
Cause of KeyError: '_errors' when running salt state.highstate
将以下内容添加到我的 minion 支柱文件后:
monit:
services:
- name: elasticsearch
pid: /var/run/elasticsearch/elasticsearch.pid
start_script: /etc/init.d/elasticsearch start
start_script: /etc/init.d/elasticsearch stop
port: 9200
当我尝试 运行 highstate 时开始收到以下错误:
root@salt-master:/home/me# salt 'my-minion-id' state.highstate -t 300
my-minion-id:
The minion function caused an exception: Traceback (most recent call last):
File "/usr/lib/python2.7/dist-packages/salt/minion.py", line 1482, in _thread_return
return_data = executor.execute()
File "/usr/lib/python2.7/dist-packages/salt/executors/direct_call.py", line 28, in execute
return self.func(*self.args, **self.kwargs)
File "/usr/lib/python2.7/dist-packages/salt/modules/state.py", line 848, in highstate
err += __pillar__['_errors']
File "/usr/lib/python2.7/dist-packages/salt/utils/context.py", line 211, in __getitem__
return self._dict()[key]
KeyError: '_errors'
这个错误很烦人,但事实证明这是因为我的 pillar 文件包含一个带有重复键的字典:
monit:
services:
- name: elasticsearch
...
start_script: /etc/init.d/elasticsearch start
start_script: /etc/init.d/elasticsearch stop
...
应该是:
monit:
services:
- name: elasticsearch
...
start_script: /etc/init.d/elasticsearch start
stop_script: /etc/init.d/elasticsearch stop
...
希望这有助于节省时间!
将以下内容添加到我的 minion 支柱文件后:
monit:
services:
- name: elasticsearch
pid: /var/run/elasticsearch/elasticsearch.pid
start_script: /etc/init.d/elasticsearch start
start_script: /etc/init.d/elasticsearch stop
port: 9200
当我尝试 运行 highstate 时开始收到以下错误:
root@salt-master:/home/me# salt 'my-minion-id' state.highstate -t 300
my-minion-id:
The minion function caused an exception: Traceback (most recent call last):
File "/usr/lib/python2.7/dist-packages/salt/minion.py", line 1482, in _thread_return
return_data = executor.execute()
File "/usr/lib/python2.7/dist-packages/salt/executors/direct_call.py", line 28, in execute
return self.func(*self.args, **self.kwargs)
File "/usr/lib/python2.7/dist-packages/salt/modules/state.py", line 848, in highstate
err += __pillar__['_errors']
File "/usr/lib/python2.7/dist-packages/salt/utils/context.py", line 211, in __getitem__
return self._dict()[key]
KeyError: '_errors'
这个错误很烦人,但事实证明这是因为我的 pillar 文件包含一个带有重复键的字典:
monit:
services:
- name: elasticsearch
...
start_script: /etc/init.d/elasticsearch start
start_script: /etc/init.d/elasticsearch stop
...
应该是:
monit:
services:
- name: elasticsearch
...
start_script: /etc/init.d/elasticsearch start
stop_script: /etc/init.d/elasticsearch stop
...
希望这有助于节省时间!