Adoptable Cookbooks List

Looking for a cookbook to adopt? You can now see a list of cookbooks available for adoption!
List of Adoptable Cookbooks

Supermarket Belongs to the Community

Supermarket belongs to the community. While Chef has the responsibility to keep it running and be stewards of its functionality, what it does and how it works is driven by the community. The chef/supermarket repository will continue to be where development of the Supermarket application takes place. Come be part of shaping the direction of Supermarket by opening issues and pull requests or by joining us on the Chef Mailing List.

Select Badges

Select Supported Platforms


machine_tag (13) Versions 1.0.1

Installs/Configures machine_tag

cookbook 'machine_tag', '= 1.0.1'
cookbook 'machine_tag', '= 1.0.1', :supermarket
knife cookbook site install machine_tag
knife cookbook site download machine_tag

machine_tag cookbook

Build Status

This cookbook provides a machine_tag resource that can create, delete, list, and search machine tags in the Vagrant and RightScale environments.


  • machine_tag gem which provides a library for using machine tags.

Vagrant Environment

For using this resource in a Vagrant environment install the following

  • Vagrant 1.2+
  • Bindler

This resource detects a Vagrant environment when the node['cloud']['provider'] is set to vagrant. This value is set automatically when the vagrant-ohai plugin is installed. For test-kitchen tests, we set this value in the .kitchen.yml file.

Bindler is used to manage Vagrant plugins required by this resource. See Bindler README on how to setup bindler.

The Vagrant plugins required by this resource to work on a Vagrant environment is put inside plugins.json file in the root of the repository. Once Bindler is set up, install these plugins by running

vagrant plugin bundle

Set a unique hostname for each VM in your Vagrantfile. To set this use the config.vm.host_name configuration key:

master.vm.host_name = "master"

See Vagrantfile for an example.

RightScale Environment

For using this resource in a RightScale Environment, the system must be a RightScale managed VM to have the required access to the rs_tag utility.



Installs the machine_tag gem.



A resource to create and delete machine_tags on a VM.

Action: create

Creates a new machine_tag on the VM.


<table> <tr> <th>Name</th> <th>Description</th> <th>Default</th> </tr> <tr> <td>name</td> <td>Name of the tag to be created</td> <td></td> </tr> </table>

Action: delete

Deletes a machine_tag from the VM.


<table> <tr> <th>Name</th> <th>Description</th> <th>Default</th> </tr> <tr> <td>name</td> <td>Name of the tag to be deleted</td> <td></td> </tr> </table>


This resource also provides two helper methods for listing and searching tags on a VM. To use them in a recipe have the following code block in the recipe

class Chef::Recipe
  include Chef::MachineTagHelper

tag_search(node, query, args)

Returns an array of tag hashes for all servers in your environment that matches the query.


<table> <tr> <th>Name</th> <th>Description</th> <th>Type</th> </tr> <tr> <td>node</td> <td>the environment (Vagrant or RightScale)</td> <td><tt>Chef::Node</tt></td> </tr> <tr> <td>query</td> <td>the tags to be queried (multiple tags are space delimited)</td> <td><tt>String</tt></td> </tr> <tr> <td>options</td> <td>optional parameters to the query</td> <td><tt>Hash</tt></td> </tr> </table>


Returns a tag hash for the current server.

<table> <tr> <th>Name</th> <th>Description</th> <th>Type</th> </tr> <tr> <td>node</td> <td>the environment (Vagrant or RightScale)</td> <td><tt>Chef::Node</tt></td> </tr> </table>


To create a machine_tag

machine_tag "namespace:predicate=value" do
  action :create

To delete a machine_tag

machine_tag "namespace:predicate=value" do
  action :delete

To list tags in the VM

class Chef::Recipe
  include Chef::MachineTagHelper

tags = tag_list(node)

To search tags in the VM

class Chef::Recipe
  include Chef::MachineTagHelper

tags = tag_list(node, 'test:tag=foo foo:bar=* some:tag')


  • node['machine_tag']['vagrant_tag_cache_dir'] - path to store the tag data for each server. Only used in Vagrant environments. This should match a config.vm.synced_folder entry in your Vagrantfile for tag_search() to work across VMs. See the Vagrantfile for an example.


Author:: RightScale, Inc. (

No quality metric results found