简体   繁体   English

错误消息

[英]Ansible error message

I'm trying to use ansible to build a docker image locally but I'm running into problems. 我正在尝试使用ansible在本地构建docker映像,但是遇到了问题。

- hosts: all
  tasks:
    - name: Build Docker image
      local_action:
          module: docker_image
          path: .
          name: SlothSloth
          state: present

And my /etc/ansible/hosts contains 我的/ etc / ansible / hosts包含

localhost   ansible_connection=local

But when I try to run it I get: 但是当我尝试运行它时,我得到:

TASK: [Build Docker image] **************************************************** 
failed: [localhost -> 127.0.0.1] => {"failed": true, "parsed": false}
failed=True msg='failed to import python module: No module named docker.client'


FATAL: all hosts have already failed -- aborting

If you are using virtualenv, you are probably running ansible with /usr/bin/python by default. 如果您使用virtualenv,则默认情况下可能使用/ usr / bin / python运行ansible。 To bypass this behavior, you have to define the variable "ansible_python_interpreter". 要绕过此行为,您必须定义变量“ ansible_python_interpreter”。

Try to use : 尝试使用:

- hosts: all
  vars:
    - ansible_python_interpreter: python
  tasks:
    - name: Build Docker image
      local_action:
          module: docker_image
          path: .
          name: SlothSloth
          state: present

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM