Philip Hallstrom
Philip Hallstrom

Reputation: 19889

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

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?"

Upvotes: 0

Views: 129

Answers (2)

George Angelopoulos
George Angelopoulos

Reputation: 54

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.

Upvotes: 1

leucos
leucos

Reputation: 18269

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.

Upvotes: 1

Related Questions