I am developing a kind of library with individual tasks
so in normal repo roles, I have something like:
roles βββ common β βββ tasks β βββ A.yml β βββ B.yml β βββ C.yml β βββ D.yml β βββ login.yml β βββ logout.yml β βββ save.yml βββ custom_stuff_workflow β βββ tasks β βββ main.yml βββ other_stuff_workflow βββ tasks βββ main.yml
my main.yml in custom_stuff_workflow then contains something like:
--- - include: login.yml - include: A.yml - include: C.yml - include: save.yml - include: logout.yml
and the other in a different workflow:
--- - include: login.yml - include: B.yml - include: A.yml - include: D.yml - include: save.yml - include: logout.yml
I canβt find a way to do this in a natural way: one of the methods that worked was that all the tasks were performed in one role and marked with the corresponding tasks, including custom_stuff_workflow
The problem with this is that the tags cannot be installed in the calling playbook: it should only be installed on the command line since I am distributing this unresolved repo to many people in the company, I cannot rely on command line calls (it would be nice, if the header #! in yml was processed by the ansible-playbook command)
I could also copy the corresponding tasks (inside the common tree in the above tree) in each workflow, but I don't want to repeat them around
Can someone see a solution to achieve what I would like without repeating tasks on different roles?
I think that the cornerstone of my problem is that I define tasks as individual, and it looks unnatural in the inaccessible ...
Thank you so much
PS: note that tasks in the workflow must be performed in a certain order, and the only natural steps for abstraction can be login and saving / logging out
PPS: I saw this question. How do I assign a role from another role in Ansible? , but it doesnβt solve my problem, since it causes a full role, not a subset of tasks in a role