Answers: <p>Instead of using a symlink that will be stored as is in BitBucket one could use:</p>
  
  <pre><code>- name: Copy docker-compose.yml
    copy:
      src: ../../../../docker-compose.yml
      dest: /path/to/docker-compose.yml
  </code></pre>
  
Answers: CC BY-SA 3.0
Answers: 2017-05-04T11:23:29.873Z
Answers: 2017-05-04T11:23:29.873Z
Answers: 030
Body: <p>Ansible is used to deploy docker-compose on a system and subsequently start the container.</p>
  
  <p>When ansible runs from the local system, the docker-compose file is deployed using Ansible.</p>
  
  <p>When the code is pushed to bitbucket the file content is:</p>
  
  <pre><code>../../../../docker-compose.yml
  </code></pre>
  
  <p>and the CI deploys this on the system as well.</p>
  
  <p><strong>Structure</strong></p>
  
  <pre><code>project/ansible
  
  project/docker-compose.yml
  
  project/ansible/roles/role/files/docker-compose.yml
  </code></pre>
  
  <p><strong>Discussion</strong></p>
  
  <p>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.</p>
  
  <p><a href="https://stackoverflow.com/a/18791647/2777965">This Q&amp;A</a> indicates that:</p>
  
  <blockquote>
    <p>The data referenced by the symlink is not stored in the repository.</p>
  </blockquote>
  
  <p>and creating a symlink to avoid code duplication in docker-compose.yml seems to cause the problem.</p>
  
Tags: <ansible><docker><bitbucket>
Title: What are best practices of deploying docker-compose using Ansible?
UserDisplayName: 030
ThreadText: # What are best practices of deploying docker-compose using Ansible?
  
  (Asked by: username_0 on 2017-05-01)
  
  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&A](https://stackoverflow.com/a/18791647/2777965) 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.
  
  **Tags:** ansible, docker, bitbucket
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_0 on 2017-05-04. Score: 2 | Accepted answer
  
  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
  
  ```
  
  
  ---
  
  