Bootstrap FreeKB - Ansible - Resolve "Error while fetching server API version"
Ansible - Resolve "Error while fetching server API version"

Updated:   |  Ansible articles

Let's say you have the following playbook, which uses one of the docker modules.

---
- hosts: aws
  remote_user: ec2-user
  tasks:
  - name: get info on the nginx container
    docker_container_info:
      name: nginx
...

 

And something like this is being returned.

fatal: [ec2-3-82-233-47.compute-1.amazonaws.com]: FAILED! => {"changed": false, "msg": "Error connecting: Error while fetching server API version: ('Connection aborted.', error(13, 'Permission denied'))"}

 

I've most often notice this when attempting to use one of the docker modules on an Amazon Web Services (AWS) EC2 instance. By default, the ec2-user must use the sudo command, thus one option is to add become: yes and become_method: sudo. If you are not familiar with become, check out my article Understanding Become Privilege Escalation.

---
- hosts: aws
  remote_user: ec2-user
  become: yes
  become_method: sudo
  tasks:
  - name: get info on the nginx container
    docker_container_info:
      name: nginx
...

 




Did you find this article helpful?

If so, consider buying me a coffee over at Buy Me A Coffee



Comments


Add a Comment


Please enter d289d3 in the box below so that we can be sure you are a human.