Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tags are ignored at role level #13795

Closed
theraser opened this issue Jan 11, 2016 · 6 comments
Closed

Tags are ignored at role level #13795

theraser opened this issue Jan 11, 2016 · 6 comments
Labels
bug This issue/PR relates to a bug.
Milestone

Comments

@theraser
Copy link

Issue Type: Bug Report
Ansible Version: ansible-playbook 2.1.0 (devel c3dd0213ef) last updated 2016/01/11 12:26:53 (GMT +200) lib/ansible/modules/core: (detached HEAD 33014c6db1) last updated 2016/01/08 15:07:37 (GMT +200) lib/ansible/modules/extras: (detached HEAD 82a4cf84be) last updated 2016/01/08 15:07:37 (GMT +200)
Environment: Ubuntu 15.04
Problem: Using tags defined for specific roles inside a playbook are ignored when running ansible-playbook with that tag, please see example for more details. Using version 1.94 this works perfectly. When tags are specified for some tasks inside this role they are usable just as expected with "--tags tag1".
Example:

[...]
- hosts: web_server
  roles:
  - role: role1
  - role: role2
  - role: ....
  tags: tag1
[...]

Running ansible-playbook -i ~/.ansible/hosts ~/.ansible/site.yml -l somehost --tags tag1 results in skipping everything:

PLAY ***************************************************************************

PLAY ***************************************************************************

PLAY ***************************************************************************
skipping: no hosts matched

PLAY ***************************************************************************

PLAY ***************************************************************************
skipping: no hosts matched

PLAY ***************************************************************************
skipping: no hosts matched

PLAY ***************************************************************************
skipping: no hosts matched

PLAY ***************************************************************************
skipping: no hosts matched

PLAY ***************************************************************************
skipping: no hosts matched
[...]
@bcoca bcoca added this to the v2 milestone Jan 11, 2016
@bcoca
Copy link
Member

bcoca commented Jan 11, 2016

when roles are skipped it does not produce a 'no hosts matched' message, that is probably related to your -l somehost

@jimi-c
Copy link
Member

jimi-c commented Jan 11, 2016

@theraser this doesn't appear to be related to tags at all, based on the output above (and my testing shows this works fine with tags). Rather, this appears to be a result of your -l somehost limit, so that you're filtering out all hosts.

Could you please share the inventory your using in this example, or some other inventory which reproduces the behavior?

@theraser
Copy link
Author

Thanks four your fast reply :-)

This indeed looks strange. When using Ansible 1.94 with exact same invocation role1, role2 [...] are executed just as expected. When Ansible development version is used I get this "skipping: no hosts matched" as you can see at top.

However I think I found the issue at my tags (syntax):
Writing something like this will work only with older Ansible versions: tags: tag1,tag2,tag3. This won't be recognized with newer versions, where you have to use the correct syntax like

tags:
  - tag1
  - tag2
  - tag3

That's why it skipped every role...

Sometimes it's that easy, sorry for wasting your time

@theraser theraser reopened this Jan 12, 2016
@jimi-c
Copy link
Member

jimi-c commented Jan 12, 2016

Hrm, that's odd, that should be split up correctly.

@theraser
Copy link
Author

I am not sure if the fact that it worked with the old version was a bug or a feature. I just rewrote my playbooks and this works now. If you need any further information please let me know, then I would try to post a complete setup

jimi-c added a commit that referenced this issue Jan 12, 2016
@jimi-c jimi-c closed this as completed in b586732 Jan 12, 2016
@jimi-c
Copy link
Member

jimi-c commented Jan 12, 2016

Closing This Ticket

Hi!

We believe the above commit should resolve this problem for you. This will also be included in the next major release.

If you continue seeing any problems related to this issue, or if you have any further questions, please let us know by stopping by one of the two mailing lists, as appropriate:

Because this project is very active, we're unlikely to see comments made on closed tickets, but the mailing list is a great way to ask questions, or post if you don't think this particular issue is resolved.

Thank you!

@ansibot ansibot added bug This issue/PR relates to a bug. and removed bug_report labels Mar 7, 2018
@ansible ansible locked and limited conversation to collaborators Apr 25, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug This issue/PR relates to a bug.
Projects
None yet
Development

No branches or pull requests

4 participants