Found part of answer for my question in How to run docker-compose commands with ansible?
- name: copy Docker Compose files
copy:
src: files/{{ item }}
dest: /somewhere/yourproject/{{ item }}
loop:
- docker-compose.yml
- docker-compose.prod.yml
# use files parameter to use multiple docker-compose.yml files
- name: deploy Docker Compose stack
docker_compose:
project_src: /somewhere/yourproject
files:
- docker-compose.yml
- docker-compose.prod.yml
But if using the module, how can I specify the path to .env if it is located in a different directory than docker-compose.yaml. If need to repeat the result of the command: docker-compose -f docker-compose.yml -f docker-compose.prod.yml --env-file=path/to/.env up
. Where the path/to/.env can change depending on the need.