ImportError:没有名为syslog的模块,ansible,edison

时间:2015-10-12 06:52:00

标签: python ansible intel-edison

我正在编写一个脚本,通过ansible将代码重新部署到intel edison上。运行以下命令时出现错误。如果可能的话,我想知道如何在本地找到导致此问题的文件。我认为在服务器上抛出错误的文件" /home/root/.ansible/tmp/ansible-tmp-1444631867.66-245111051532005/setup" ;,可能是从本地仓库中的文件生成的。

但是,我似乎无法在本地找到此安装文件,并且在抛出错误后,ansible会从服务器(爱迪生)中删除此文件。

$ ansible-playbook -i inventory.yml provision_edison.yml

failed: [192.168.1.196] => {"failed": true, "parsed": false}
Traceback (most recent call last):
  File "/home/root/.ansible/tmp/ansible-tmp-1444631867.66-245111051532005/setup", line 196, in <module>
import syslog
ImportError: No module named syslog
OpenSSH_6.2p2, OSSLShim 0.9.8r 8 Dec 2011

我的库存文件inventory.yml

[edisons]
192.168.1.196

我的provision_edison.yml文件

 ---
 - hosts: edisons
   remote_user: root
   tasks:
     - name: "test if stuff is working"
       shell: uname -a

我将此识别为服务器上发生的python导入错误。我试着查看服务器抛出的行号196是否对应于我本地的文件,但没有运气。

 root@edison-01:/usr/bin# ./python
 Python 2.7.3 (default, Aug 15 2014, 22:34:09) 
 [GCC 4.8.2] on linux2
 Type "help", "copyright", "credits" or "license" for more information.
 >>> import syslog
 Traceback (most recent call last):
   File "<stdin>", line 1, in <module>
 ImportError: No module named syslog

2 个答案:

答案 0 :(得分:0)

关于你的Python环境的一些东西必须关闭。 syslog已成为标准库的一部分,因为至少2.6。这是一台基于unix的机器吗?这是一个干净的Python安装吗?我会检查你的Python路径之类的东西,看看你是否可以在那个盒子上导入其他标准库。

答案 1 :(得分:0)

许多一次性Python构建不包括syslog库,即使它在技术上是核心的一部分。应通过以下提交在Ansible 2.0中修复此问题:https://github.com/ansible/ansible/commit/c57200925f7fc3c77da9a0b671ef7328cad15d8d