Run a single role in playbook

114 views
Skip to first unread message

Andrew Craft

unread,
Jan 21, 2015, 6:03:34 AM1/21/15
to ansible...@googlegroups.com
In the same way that you can use tags to target specific tasks in a large playbook, is it possible to filter by roles? Tags are useful but often find i am tagging all tasks in a role with same tag so i can run just those, would be nice if I could use roles in a similar way to filter as tags?

thanks

Pål Nilsen

unread,
Jan 21, 2015, 6:18:54 AM1/21/15
to ansible...@googlegroups.com
You could always create a separate file with something like:
-
  host
s: all
  roles
:
   
- role1
   
- role2

ansible-playbook -i hosts the_file_above.yml --limit host1,host2

It gets cumbersome to edit that file or create new ones all the time though, but I don't know of a better way. I always tag all my tasks inside roles with sensible tags to easily filter with --tags / --skip-tags, though.

junkmailt...@gmail.com

unread,
Jan 21, 2015, 7:37:20 AM1/21/15
to ansible...@googlegroups.com
You can tag your role just like anything else. Doing so effectively runs the role as if every task inside the role has the tag.

roles:
 
- role: myCoolRole,
    tags
: tagsAreCool

Andrew Craft

unread,
Jan 21, 2015, 7:46:31 AM1/21/15
to ansible...@googlegroups.com
yep but have to go through and do it for each role and each playbook i want to that, would be nice if there was something like an implicit tag for each role.

--
You received this message because you are subscribed to a topic in the Google Groups "Ansible Project" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ansible-project/9BEBajCGwWI/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/59d50c0e-4a9d-412a-990e-2b2df73956ca%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages