Should tags work on includes?

Hello all…

In the docs here it suggests that I should be able to add tags to an include statement like this:


  • include: site.yml tags=foo

This simple playbook works fine unless I try actually doing anything with tags, like this:

ansible-playbook -i hosts foo.yml --tags foo

which gives me an error:

ERROR: tag(s) not found in playbook: foo. possible values:

The documentation suggests this should work. Am I doing something foolish?

Many thanks!
Quentin

Hi,

This was asked recently.

Tags work on task includes, and roles.

They do not currently do anything on playbook level includes.

This is something we may consider after the current refactoring effort (1.9 timeframe) completes.

That’s a common logical error that I’ve come across too. Tags aren’t called, they are only applied in playbooks, someone might be able to word that better.

The only way to call a tag is when running ansible playbook.

I spoke to Michael after Ansible fest San Fran and he mentioned that other are having this issue too.

I’m not sure if this is being addressed, someone else might know off the top of their head?

Stephen

Thanks, all…

I can work around them for now. Apologies for not seeing the earlier message. I did try searching but didn’t find it. Ironic, on a Google site :slight_smile:

Q

“That’s a common logical error that I’ve come across too. Tags aren’t called, they are only applied in playbooks, someone might be able to word that better.”

Unless I didn’t follow, I don’t think that was the above misunderstanding, but it is true that the include directive “labels” things with tags. It’s just not true you can label tags when you do a playbook include.

(It is true that including doesn’t select things with certain tags, as well)

I agree – Google is rough at search for everything but Google.com – Gmail also, grr :slight_smile: