Syntax error while using Ansible docker module

Hello,
I mm new to Ansible and trying to use its docker module to start docker containers. I have all the prereqs installed on the docker host

  • python >= 2.6
  • docker-py >= 0.3.0
  • The docker server >= 0.10.0

But i get a syntax error while trying to run the ansible playbook. No clue why its throwing that error. Any ideas on what am i missing here ?

$ ansible-playbook -vvvv -i hosts …/wildfly-docker.yml
ERROR: Syntax Error while loading YAML script, …/wildfly-docker.yml
Note: The error may actually appear before this position: line 7, column 5

docker:
name: wildfly-1
^

Here is my playbook file

This error got fixed when i moved the section under tasks to a different YML file and included that file in this one and it worked :slight_smile:

Although i got moved to new error now
TASK: [Wildfly container#1] ***************************************************
failed: [159.203.249.12] => {“error”: “NotFound(HTTPError(u’404 Client Error: Not Found for url: http+docker://localunixsocket/v1.20/images/create?tag=latest&fromImage=jboss%2Fwildfly’,),)”, “failed”: true}
msg: Failed to pull the specified image: jboss/wildfly

Doing ‘docker pull jboss/wildfly’ directly on the host works fine.

Thanks
-Kunal

Anyone has a clue on this ? Would appreciate any feedback on this.

Thanks

are you doing the docker pull with root directly on the machine too? Maybe some of the environment variables that are needed to make the connection are not loaded.

Hi Kunal,

I don’t have a machine to confirm, but I guess there is a syntax error in your playbook. A new block should have two spaces of indentation. Try to make that change and see.

Regards,
Vikas