patterndockerMinor
What are best practices of deploying docker-compose using Ansible?
Viewed 0 times
deployingwhataredockerpracticescomposeusingansiblebest
Problem
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:
and the CI deploys this on the system as well.
Structure
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 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.
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.ymland the CI deploys this on the system as well.
Structure
project/ansible
project/docker-compose.yml
project/ansible/roles/role/files/docker-compose.ymlDiscussion
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 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.
Solution
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.ymlCode Snippets
- name: Copy docker-compose.yml
copy:
src: ../../../../docker-compose.yml
dest: /path/to/docker-compose.ymlContext
StackExchange DevOps Q#1082, answer score: 2
Revisions (0)
No revisions yet.