1

I am using ansible and docker_container module. But when I start my playbook, I have error like:

"'depends_on' is not a valid attribute for a Task"

This is my playbook:

- name: Docker-compose
  hosts: localhost
  connection: local
  gather_facts: no  
  tasks:
    - name: Start selenium hub
      docker_container:
        name: hub
        image: selenium:latest
        state: started
        restart: yes
        ports:
          - "4444:4444"

    - name: Start chromedriver
      docker_container:
        name: chromedriver
        image: chromedriver:latest
        state: started
        restart: yes
        depends_on:
          - "hub"
        links:
          - "hub:hub"  
        env:
            VNC_ENABLED: true
            EXPOSE_X11: true
        ports:
          - "5900:5900"

As you can see container with name 'chromedriver' depends on 'hub'. How can I do this?

  • Note that I couldn't reproduce this playbook with the images that you use as examples - perhaps they are private for you. However, there are a few public selenium and chromedriver images which you may want to use. – Bruce Becker Oct 31 '18 at 10:07
0

The Ansible docker_container module indeed has no depends_on attribute. You should create the containers in order to simulate the dependency tree.

The previous task indeed does this, so just remove the depends_on attribute and the task should complete properly.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.