Skip to content
This repository was archived by the owner on May 9, 2020. It is now read-only.

Commit 3c21069

Browse files
committed
Document chef_query and chef_tags.
1 parent 98a5809 commit 3c21069

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

chef/fabric.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,21 @@ def chef_environment(name, api=None):
151151

152152

153153
def chef_query(query, api=None, hostname_attr=DEFAULT_HOSTNAME_ATTR, environment=_default_environment):
154+
"""A decorator to use an arbitrary Chef search query to find nodes to execute on.
155+
156+
This is used like Fabric's ``roles()`` decorator, but accepts a Chef search query.
157+
158+
Example::
159+
160+
from chef.fabric import chef_query
161+
162+
@chef_query('roles:web AND tags:active')
163+
@task
164+
def deploy():
165+
pass
166+
167+
.. versionadded:: 0.2.1
168+
"""
154169
api = _api(api)
155170
if api.version_parsed < Environment.api_version_parsed and environment is not None:
156171
raise ChefAPIVersionError('Environment support requires Chef API 0.10 or greater')
@@ -160,6 +175,21 @@ def chef_query(query, api=None, hostname_attr=DEFAULT_HOSTNAME_ATTR, environment
160175

161176

162177
def chef_tags(*tags, **kwargs):
178+
"""A decorator to use Chef node tags to find nodes to execute on.
179+
180+
This is used like Fabric's ``roles()`` decorator, but accepts a list of tags.
181+
182+
Example::
183+
184+
from chef.fabric import chef_tags
185+
186+
@chef_tags('active', 'migrator')
187+
@task
188+
def migrate():
189+
pass
190+
191+
.. versionadded:: 0.2.1
192+
"""
163193
# Allow passing a single iterable
164194
if len(tags) == 1 and not isinstance(tags[0], basestring):
165195
tags = tags[0]

0 commit comments

Comments
 (0)