What are best practices of deploying docker-compose using Ansible? Ansible is used to deploy docker-compose on a system and subsequently start the container.

When ansible runs from the local system, the docker-compose file is deployed using Ansible.

When the code is pushed to bitbucket the file content is:

../../../../docker-compose.yml


and the CI deploys this on the system as well.

Structure

project/ansible

project/docker-compose.yml

project/ansible/roles/role/files/docker-compose.yml


Discussion

In order to prevent that the docker-compose.yml need to be changed on two places, a symlink has been created, but that seems to be ignored by bitbucket as the link instead of the content reside in this file.

This Q&amp;A indicates that:


  The data referenced by the symlink is not stored in the repository.


and creating a symlink to avoid code duplication in docker-compose.yml seems to cause the problem.
Instead of using a symlink that will be stored as is in BitBucket one could use:

- name: Copy docker-compose.yml
  copy:
    src: ../../../../docker-compose.yml
    dest: /path/to/docker-compose.yml