On Wed, 24 Feb 2021 09:05:27 -0800 (PST)
Mouton Noir <
the.m0u...@gmail.com> wrote:
> Every task in the main.yml from "myrole" are conditioned with a different
> value for a variable myowntags
> ex:
> when: myowntags == "fst-openshot"
>
> Then, in a taskfile or playbook, I can select the tasks I want with
> something like :
> - name: test
> include_role:
> name: myrole
> vars:
> myowntags: "fst-openshot"
>
> As this role is only dedicated to pick up some tasks when needed (not
> applied to any group as itself), it makes it for me.
Next option would be to fragment main.yml and put the tasks into
the separate files, e.g
shell> cat main.yml
- import_tasks: tasks01.yml
- import_tasks: tasks02.yml
...
This would keep the original functionality untouched. Now, create
files with the logical blocks you'd like to use, e.g.
shell: cat fst-openshot.yml
- import_tasks: tasks07.yml
- import_tasks: tasks25.yml
- import_tasks: tasks33.yml
Then, it would be possible to include such blocks selectively, e.g.
- name: test
include_role:
name: myrole
tasks_from: "{{ myowntags }}.yml"
--
Vladimir Botka