How can I say "all these tasks should have this tag" when including yml files?

StackOverflow https://stackoverflow.com/questions/22103541

  •  18-10-2022
  •  | 
  •  

Question

In my roles/common/main.yml I have - include ruby2.yml. That file has 3-4 tasks and each one has tags: ruby2. Works fine, but feels repetitive. The documentation says that when doing the include I could write it like this: - include: ruby2.yml tags=ruby2

But that puts the responsibility outside of the file itself which bugs me for some reason.

Is there a way, within ruby2.yml to say "all of these tasks should have the 'ruby2' tag?"

Was it helpful?

Solution

leucos' answer is actually incorrect.

- include: ruby2.yml tags=ruby2

The above will tag every task in ruby2.yml with the ruby2 tag, just as OP already mentioned.

This is clearly and explicitly documented here.

OTHER TIPS

AFAIK, there is no way to do that, and this is infortunate !

Note that

- include: ruby2.yml tags=ruby2

means "from ruby2.yml import tasks that have the 'ruby2' tag". It does not apply a tag to all actions.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top