Saltstack smtp.send_msg 返回属性错误
Saltstack smtp.send_msg returning with attribute error
我设置了一个信标,用于跟踪 Ubuntu Server 16.04 上所有 Ubuntu Server 16.04 minions 的磁盘使用情况。我们想要一个反应器,当磁盘 space 达到某个点时,它会向我们发送电子邮件。本题侧重于master发送邮件的能力。当我 运行 在 salt-master 上执行以下命令时:
sudo salt-call smtp.send_msg 'email@email.com' 'Test message 3' subject='Test subject 3' profile='smtp-default'
我得到以下结果:
[ERROR ] An un-handled exception was caught by salt's global exception handler:
AttributeError: 'str' object has no attribute 'get'
Traceback (most recent call last):
File "/usr/bin/salt-call", line 11, in <module>
salt_call()
File "/usr/lib/python2.7/dist-packages/salt/scripts.py", line 391, in salt_call
client.run()
File "/usr/lib/python2.7/dist-packages/salt/cli/call.py", line 58, in run
caller.run()
File "/usr/lib/python2.7/dist-packages/salt/cli/caller.py", line 134, in run
ret = self.call()
File "/usr/lib/python2.7/dist-packages/salt/cli/caller.py", line 204, in call
ret['return'] = func(*args, **kwargs)
File "/usr/lib/python2.7/dist-packages/salt/modules/smtp.py", line 95, in send_msg
server = creds.get('smtp.server')
AttributeError: 'str' object has no attribute 'get'
Traceback (most recent call last):
File "/usr/bin/salt-call", line 11, in <module>
salt_call()
File "/usr/lib/python2.7/dist-packages/salt/scripts.py", line 391, in salt_call
client.run()
File "/usr/lib/python2.7/dist-packages/salt/cli/call.py", line 58, in run
caller.run()
File "/usr/lib/python2.7/dist-packages/salt/cli/caller.py", line 134, in run
ret = self.call()
File "/usr/lib/python2.7/dist-packages/salt/cli/caller.py", line 204, in call
ret['return'] = func(*args, **kwargs)
File "/usr/lib/python2.7/dist-packages/salt/modules/smtp.py", line 95, in send_msg
server = creds.get('smtp.server')
AttributeError: 'str' object has no attribute 'get'
这是我的 salt --versions-report master 的输出,returns 错误:
Salt Version:
Salt: 2017.7.1
Dependency Versions:
cffi: 1.10.0
cherrypy: unknown
dateutil: 2.4.2
docker-py: Not Installed
gitdb: 0.6.4
gitpython: 1.0.1
ioflo: Not Installed
Jinja2: 2.8
libgit2: Not Installed
libnacl: Not Installed
M2Crypto: Not Installed
Mako: 1.0.3
msgpack-pure: Not Installed
msgpack-python: 0.4.6
mysql-python: Not Installed
pycparser: 2.18
pycrypto: 2.6.1
pycryptodome: Not Installed
pygit2: Not Installed
Python: 2.7.12 (default, Nov 19 2016, 06:48:10)
python-gnupg: Not Installed
PyYAML: 3.11
PyZMQ: 15.2.0
RAET: Not Installed
smmap: 0.9.0
timelib: Not Installed
Tornado: 4.2.1
ZMQ: 4.1.4
System Versions:
dist: Ubuntu 16.04 xenial
locale: UTF-8
machine: x86_64
release: 4.4.0-93-generic
system: Linux
version: Ubuntu 16.04 xenial
我已经卸载并重新安装了 salt-master 和 salt-minion,并且更新了 Python 和 salt-master。我还创建了另一个 salt-master,它 运行 遇到了同样的问题。对此有何修复或解决方案?
我发现错误与安装的 Python 库无关,也与我的系统是否更新无关。我发现我没有设置 SMTP 服务器,我需要创建一个 SMTP 邮件服务器或有一个可访问的 SMTP 邮件服务器,以便发送电子邮件作为反应器系统的通知。我发现解决方案是设置一个 SMTP 邮件服务器,然后在 /etc/salt/minion.d 目录中创建一个引用 SMTP 邮件服务器的 .conf 文件,如下所示:
smtp-default:
smtp.sender: mail@example.com
smtp.server: 0.0.0.0
smtp.tls: false
在创建了一个与上述类似的 .conf 文件和引用状态文件的函数声明的 salt-call 命令的配置文件后,我能够将电子邮件发送到所需的地址。
我设置了一个信标,用于跟踪 Ubuntu Server 16.04 上所有 Ubuntu Server 16.04 minions 的磁盘使用情况。我们想要一个反应器,当磁盘 space 达到某个点时,它会向我们发送电子邮件。本题侧重于master发送邮件的能力。当我 运行 在 salt-master 上执行以下命令时:
sudo salt-call smtp.send_msg 'email@email.com' 'Test message 3' subject='Test subject 3' profile='smtp-default'
我得到以下结果:
[ERROR ] An un-handled exception was caught by salt's global exception handler:
AttributeError: 'str' object has no attribute 'get'
Traceback (most recent call last):
File "/usr/bin/salt-call", line 11, in <module>
salt_call()
File "/usr/lib/python2.7/dist-packages/salt/scripts.py", line 391, in salt_call
client.run()
File "/usr/lib/python2.7/dist-packages/salt/cli/call.py", line 58, in run
caller.run()
File "/usr/lib/python2.7/dist-packages/salt/cli/caller.py", line 134, in run
ret = self.call()
File "/usr/lib/python2.7/dist-packages/salt/cli/caller.py", line 204, in call
ret['return'] = func(*args, **kwargs)
File "/usr/lib/python2.7/dist-packages/salt/modules/smtp.py", line 95, in send_msg
server = creds.get('smtp.server')
AttributeError: 'str' object has no attribute 'get'
Traceback (most recent call last):
File "/usr/bin/salt-call", line 11, in <module>
salt_call()
File "/usr/lib/python2.7/dist-packages/salt/scripts.py", line 391, in salt_call
client.run()
File "/usr/lib/python2.7/dist-packages/salt/cli/call.py", line 58, in run
caller.run()
File "/usr/lib/python2.7/dist-packages/salt/cli/caller.py", line 134, in run
ret = self.call()
File "/usr/lib/python2.7/dist-packages/salt/cli/caller.py", line 204, in call
ret['return'] = func(*args, **kwargs)
File "/usr/lib/python2.7/dist-packages/salt/modules/smtp.py", line 95, in send_msg
server = creds.get('smtp.server')
AttributeError: 'str' object has no attribute 'get'
这是我的 salt --versions-report master 的输出,returns 错误:
Salt Version:
Salt: 2017.7.1
Dependency Versions:
cffi: 1.10.0
cherrypy: unknown
dateutil: 2.4.2
docker-py: Not Installed
gitdb: 0.6.4
gitpython: 1.0.1
ioflo: Not Installed
Jinja2: 2.8
libgit2: Not Installed
libnacl: Not Installed
M2Crypto: Not Installed
Mako: 1.0.3
msgpack-pure: Not Installed
msgpack-python: 0.4.6
mysql-python: Not Installed
pycparser: 2.18
pycrypto: 2.6.1
pycryptodome: Not Installed
pygit2: Not Installed
Python: 2.7.12 (default, Nov 19 2016, 06:48:10)
python-gnupg: Not Installed
PyYAML: 3.11
PyZMQ: 15.2.0
RAET: Not Installed
smmap: 0.9.0
timelib: Not Installed
Tornado: 4.2.1
ZMQ: 4.1.4
System Versions:
dist: Ubuntu 16.04 xenial
locale: UTF-8
machine: x86_64
release: 4.4.0-93-generic
system: Linux
version: Ubuntu 16.04 xenial
我已经卸载并重新安装了 salt-master 和 salt-minion,并且更新了 Python 和 salt-master。我还创建了另一个 salt-master,它 运行 遇到了同样的问题。对此有何修复或解决方案?
我发现错误与安装的 Python 库无关,也与我的系统是否更新无关。我发现我没有设置 SMTP 服务器,我需要创建一个 SMTP 邮件服务器或有一个可访问的 SMTP 邮件服务器,以便发送电子邮件作为反应器系统的通知。我发现解决方案是设置一个 SMTP 邮件服务器,然后在 /etc/salt/minion.d 目录中创建一个引用 SMTP 邮件服务器的 .conf 文件,如下所示:
smtp-default:
smtp.sender: mail@example.com
smtp.server: 0.0.0.0
smtp.tls: false
在创建了一个与上述类似的 .conf 文件和引用状态文件的函数声明的 salt-call 命令的配置文件后,我能够将电子邮件发送到所需的地址。