docker service is not runing via ansible

  ansible, docker, docker-compose

I am trying to run a service via ansible

- name: Run airflow init
  shell:
      cmd: docker-compose up airflow-init
      chdir: /home/azureuser/airflow

but it is throwing this error:

fatal: [dmpServer]: FAILED! => {"changed": true, "cmd": "docker-compose up airflow-init", "delta": "0:00:01.016183", "end": "2021-06-29 01:26:01.836135", "msg": "non-zero return code", "rc": 1, "start": "2021-06-29 01:26:00.819952", "stderr": "/usr/local/lib/python2.7/dist-packages/paramiko/transport.py:33: CryptographyDeprecationWarning: Python 2 is no longer supported by the Python core team. Support for it is now deprecated in cryptography, and will be removed in the next release.n  from cryptography.hazmat.backends import default_backendnThe Compose file './docker-compose.yaml' is invalid because:nInvalid top-level property "x-airflow-common". Valid top-level sections for this Compose file are: services, version, networks, volumes, and extensions starting with "x-".nnYou might be seeing this error because you're using the wrong Compose file version. Either specify a supported version (e.g "2.2" or "3.3") and place your service definitions under the `services` key, or omit the `version` key and place your service definitions at the root of the file to use version 1.nFor more on the Compose file format versions, see https://docs.docker.com/compose/compose-file/nservices.airflow-init.depends_on contains an invalid type, it should be an arraynservices.airflow-scheduler.depends_on contains an invalid type, it should be an arraynservices.airflow-webserver.depends_on contains an invalid type, it should be an arraynservices.airflow-worker.depends_on contains an invalid type, it should be an arraynservices.flower.depends_on contains an invalid type, it should be an array", "stderr_lines": ["/usr/local/lib/python2.7/dist-packages/paramiko/transport.py:33: CryptographyDeprecationWarning: Python 2 is no longer supported by the Python core team. Support for it is now deprecated in cryptography, and will be removed in the next release.", "  from cryptography.hazmat.backends import default_backend", "The Compose file './docker-compose.yaml' is invalid because:", "Invalid top-level property "x-airflow-common". Valid top-level sections for this Compose file are: services, version, networks, volumes, and extensions starting with "x-".", "", "You might be seeing this error because you're using the wrong Compose file version. Either specify a supported version (e.g "2.2" or "3.3") and place your service definitions under the `services` key, or omit the `version` key and place your service definitions at the root of the file to use version 1.", "For more on the Compose file format versions, see https://docs.docker.com/compose/compose-file/", "services.airflow-init.depends_on contains an invalid type, it should be an array", "services.airflow-scheduler.depends_on contains an invalid type, it should be an array", "services.airflow-webserver.depends_on contains an invalid type, it should be an array", "services.airflow-worker.depends_on contains an invalid type, it should be an array", "services.flower.depends_on contains an invalid type, it should be an array"], "stdout": "", "stdout_lines": []}

Even though I have installed Python 3.

[email protected]:airflow# python3 -V
Python 3.6.9

How to resolve this issue?

Regards
Rajaniesh

Source: Docker Questions

LEAVE A COMMENT