Description
SUMMARY
When role A includes role B as dependency, role B can access files & templates from role A's directories using a relative path if this path does not exists in its own directories. This works for nearly all builtin modules from Ansible (EDIT: found the documentation, see here). This also works for the copy module but not for synchronize.
I marked it as a feature request, because this feature is nowhere stated for synchronize itself.
ISSUE TYPE
- Feature Idea
COMPONENT NAME
ansible.posix.synchronize
ADDITIONAL INFORMATION
This feature helps to e.g. create a role managing a docker-compose project in general (upload repo with docker-compose.yml and Dockerfiles, build & launch compose, configure other stuff required, …), further called "role_b", which can be reused by multiple roles holding the repo with docker-compose.yml and Dockerfiles for certain services, further called "role_a".
The multi file example I describe below shows what works with copy and what I want to do with synchronize:
Example files with contents
site.yml
# run example locally
- hosts: localhost
connection: local
gather_facts: no
roles:
- role: role_a
roles/role_a/meta/main.yml
# this role holds a repo in its files/ directory
dependencies:
# include role with copy/synchronize
- name: role_b
roles/role_a/files/repo/docker-compose.yml
# Imagine a docker-compose.yml using multiple Dockerfiles …
roles/role_a/files/repo/Dockerfile
# Imagine multiple Dockerfiles used by docker-compose.yml
roles/role_b/tasks/main.yml
# check_mode so nothing will be applied
# this works
- name: Copy temp
check_mode: yes
ansible.builtin.copy:
src: repo/
dest: /tmp
# this not
- name: Sync temp
check_mode: yes
ansible.posix.synchronize:
mode: push
src: repo/
dest: /tmp
ignore_errors: yes