Cookbooks

The cookbooks resource adds support for querying chef cookbooks.

Supported Operations

Index Fetch a list of all of the groups
Exists Check if a group exists
Contents Get the list of files in a cookbook
Parse Filename Splits up the path to a file in a cookbook
File Content Read the contents of a file

API Reference

class pastry.resources.cookbooks.Cookbooks[source]

Provides methods for interacting with chef cookbooks

classmethod contents(cookbook, version='_latest')[source]

Fetches the cookbooks list of files that chef knows about

Parameters:
  • cookbook (string) – The cookbook’s name
  • version (string) – The cookbook’s version
Returns:

All of the files the cookbook knows about

Return type:

hash

classmethod exists(cookbook)[source]

Checks if a cookbook exists on the chef server

Parameters:cookbook (string) – The Cookbook’s name
Returns:If the cookbook exists
Return type:boolean
classmethod file_content(cookbook, filename, version='_latest')[source]

Fetches the contents of a specific file in a cookbook

Parameters:
  • cookbook (string) – The cookbook’s name
  • filename (string) – The name (and path) of the file to fetch
  • version (string) – The cookbook’s version
Returns:

The raw contents of the specified file

Return type:

string

classmethod index()[source]

Fetches all of the cookbooks (and versions) on the chef server

Returns:All the chef cookbooks and versions
Return type:hash
classmethod parse_filename(filename)[source]

Splits the file path so that it can be used to call the chef api

Parameters:filename (string) – The file’s path relative to the cookbook root
Returns:The type of file, specificity, and filename
Return type:iterable