ansible - 使用命令/shell 模块导致 : ValueError: Key name may not begin with an underscore on multiple runs

标签 ansible

Ansible 会在每个使用 shell 或命令模块的任务上抛出错误,但在新机器上首次运行时不会。

我使用的过程是镜像一个新的树莓派,然后使用ansible设置我需要的服务。第一次运行 ansible 工作正常,但如果我再次运行它(不改变任何东西)它失败,说 ValueError: Key name may not begin with an underscore

这是一个抛出错误的任务示例。在远程机器上运行 /usr/local/bin/pigpiod -v 工作正常/

- name: see if pigpiod is the correct version
  command: "/usr/local/bin/pigpiod -v"
  register: pigpiod_version

这里是错误:

An exception occurred during task execution. To see the full traceback, use -vvv. The error was: ValueError: Key name may not begin with an underscore
fatal: [issacs_box]: FAILED! => {"changed": false, "module_stderr": "Traceback (most recent call last):\n  File \"<stdin>\", line 113, in <module>\n  File \"<stdin>\", line 105, in _ansiballz_main\n  File \"<stdin>\", line 48, in invoke_module\n  File \"/usr/lib/python3.5/imp.py\", line 234, in load_module\n    return load_source(name, filename, file)\n  File \"/usr/lib/python3.5/imp.py\", line 170, in load_source\n    module = _exec(spec, sys.modules[name])\n  File \"<frozen importlib._bootstrap>\", line 626, in _exec\n  File \"<frozen importlib._bootstrap_external>\", line 673, in exec_module\n  File \"<frozen importlib._bootstrap>\", line 222, in _call_with_frames_removed\n  File \"/tmp/ansible_command_payload_hc3z4iej/__main__.py\", line 292, in <module>\n  File \"/tmp/ansible_command_payload_hc3z4iej/__main__.py\", line 199, in main\n  File \"/tmp/ansible_command_payload_hc3z4iej/ansible_command_payload.zip/ansible/module_utils/basic.py\", line 901, in __init__\n  File \"/tmp/ansible_command_payload_hc3z4iej/ansible_command_payload.zip/ansible/module_utils/basic.py\", line 2243, in _log_invocation\n  File \"/tmp/ansible_command_payload_hc3z4iej/ansible_command_payload.zip/ansible/module_utils/basic.py\", line 2201, in log\n  File \"systemd/_journal.pyx\", line 68, in systemd._journal.send\n  File \"systemd/_journal.pyx\", line 32, in systemd._journal._send\nValueError: Key name may not begin with an underscore\n", "module_stdout": "", "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error", "rc": 1}

最佳答案

我安装了错误的 PYPI 包。巧合的是,有一个名为 systemd(版本 0.16.1)的包与官方的 systemd-python(版本 234)包不同。运行 pip3 uninstall systemd 然后 pip3 install systemd-python --user 解决了问题。

关于ansible - 使用命令/shell 模块导致 : ValueError: Key name may not begin with an underscore on multiple runs,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57205008/

相关文章:

python - Ansible - 尝试 python3.5 时找不到 Virtualenv 可执行文件

shell - 如果存在则从 ansible playbook 中删除

variables - Ansible 从 ansible play/playbook 获取 "hosts"键的值

使用 Ansible 进行 Vagrant 配置失败

Ansible 剧本 : load internal inventory file while running

python - 如何通过 Ansible 远程执行具有多个模块的 Python?

ansible - 防止 Ansible 将变量中的\a 更改为\u0007

python - ansible 剧本 : No package matching 'python-pip' found available -on centos guest 出错

python-3.x - ansible 剧本错误为 : ModuleNotFoundError: No module named 'azure.mgmt.monitor.version' although the module is installed

ansible - 如何从 ansible 任务将成员添加到 LDAP 组