roles and tasks reusability

Hello everyone,

I did not found a elegant way of sharing tasks list between roles.
I explain my problem :

1 I have a first role in which i include tasks (IE create_user.yml) so i put the file in my_firt_role/tasks/create_user.yml
2 I am writing an other role in which i would like to use the tasks create_user.yml too

The only solutions i found to use it in both playbooks are :

hardcode the path of a common dir in my roles includes ( /var/ansible/common/create_user.yml)
duplicate the tasks in each playbook

I was expecting a way to configure tasks lookup directories (like role_path for roles) in ansible.cfg
I try also to add a role dependencies but it seems that the pulled roles are not sharing tasks to upper roles.

Am I missing an Ansible feature or good practice ?
Any ideas to improve tasks re-usability and avoid duplication ?

Regards,

Efflam

I finaly found a workaround :

ansible seems to lookup in tasks directory (even symlinks)
/etc/ansible/specific_utils/
├── utils_stuff1.yml
└── utils_stuff2.yml
/etc/ansible/common/
├── common_stuff1.yml
└── common_stuff2.yml

/path/to/your/ansible/workdir
├── tasks → …/…/…/…/etc/ansible/common
└── your_role
└── tasks
├── main.yml

└── tasks → …/…/…/…/…/…/…/etc/ansible/specific_utils

You could use the include_role module like this:

include_role:
name: my_flirt_role
tasks_from: create_user