Herve Meftah
Herve Meftah

Reputation: 1075

Ansible Docker exec failed with docker not found in path?

Using docker with ansible, the simulation of a docker exec process failed with an awkward error

---
- hosts: centos
  become: true
  tasks:
    - name: create jenkins container
      docker_container:
        name: my_jenkins
        image: jenkins

    - name: add container to inventory
      add_host:
        name: my_jenkins
        ansible_connection: docker
        ansible_user: jenkins
      changed_when: false

    - name: create directory for ssh keys
      delegate_to: my_jenkins
      file:
        path: "/var/jenkins_home/.ssh/jupiter"
        state: directory

error

TASK [create directory for ssh keys] ***********************************************************************************
fatal: [apollo]: FAILED! => {"msg": "docker command not found in PATH"}

Upvotes: 0

Views: 3031

Answers (1)

David J Eddy
David J Eddy

Reputation: 2037

"docker command not found in PATH" means that Ansible tried to execute the docker command but the docker executable could not be found. echo $PATH to see the current dir. paths that are searched for executable.

Given that Ansible is able to complete step 1 and 2, my assumption is that the docker daemon did indeed install successfully. So

  1. Add the path to the Docker daemon to the systems $PATH Install.

  2. Docker into a path that is already included in the $PATH.

Hope this helps out.

Upvotes: 1

Related Questions