tags with roles

Hi All,

I want to use tags inside the roles, here is my usecase:

I want to execute tasks marked with aaaa from testrole:

[root@wildfly ~/ansible]$ cat test.yml

Hi Vlado,

I think you are misunderstanding the feature. There is no sub
-election with tags on role definition, when you:
- {role: testrole, tags: ['aaaa']}

What you are doing is tagging all tasks in testrole with 'aaaa' on top
of existing tags. So it would look like this once imported:

- name: aaaa tag
  local_action: command echo
  tags:
    - aaaa

- name: bbbb tag
  local_action: command echo
  tags:
    - bbbb
    - aaaa

You are not saying 'run only those tagged with 'aaaa', that is not
possible when specifying a role to import.
I suggest making 2 roles and only importing the one with the tasks you
want to execute.

Hi Brain,

thanks for the explanation. Here is similar problem we have:
We have a download role which should download something from given location(web, maven, local).
So when location is maven, I dont want to execute http steps.
But when “when” statement is after include this means that all tasks in included yml will be executed with it.
But i would like to skip complete yml.

the when will be applied to each task, so they will be skipped

this is current state:

when you want to implement this
if(x=true)
task1
task2
task3
task4
task5
if(y=true)
task6
task7

you should write when to each task:

task1 when x
task2 when x
task3 when x
task4 when x
task5 when x
task6 when y
task7 when y

but when there would be something like goto, you could save many whens, and it would have the desired effect that task would be completely skipped:

goto label when x != true
task1
task2
task3
tast4
tast6

label

goto end when y !=true

tast6
tast7
end

you can write the when in the include or in 2.0 use blocks