def chef_tags(*tags, **kwargs):
"""A decorator to use Chef node tags to find nodes to execute on.
This is used like Fabric's ``roles()`` decorator, but accepts a list of tags.
Example::
from chef.fabric import chef_tags
@chef_tags('active', 'migrator')
@task
def migrate():
pass
.. versionadded:: 0.2.1
"""
# Allow passing a single iterable
if len(tags) == 1 and not isinstance(tags[0], six.string_types):
tags = tags[0]
query = ' AND '.join('tags:%s'%tag.strip() for tag in tags)
return chef_query(query, **kwargs)
评论列表
文章目录