简体   繁体   中英

Ansible error message

I'm trying to use ansible to build a docker image locally but I'm running into problems.

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

And my /etc/ansible/hosts contains

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. To bypass this behavior, you have to define the variable "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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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