cookbook 'machine_tag', '~> 2.0.4'
machine_tag (13) Versions 2.0.4 Follow0
Installs/Configures machine_tag
cookbook 'machine_tag', '~> 2.0.4', :supermarket
knife supermarket install machine_tag
knife supermarket download machine_tag
machine_tag cookbook
This cookbook provides a machine_tag
resource that can create, delete, list, and
search machine tags in the Vagrant and RightScale environments.
Github Repository: https://github.com/rightscale-cookbooks/machine_tag
Requirements
- machine_tag gem which provides a library for using machine tags.
- Requires Ruby 2.3.1
- Chef 12
- Requires RightLink 10 See cookbook version 1.0.9 for RightLink 6 support
- Platform
- Ubuntu 12.04, 14.04
- CentOS 6, 7
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
RightLink 6
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.
RightLink 10
For using this resource in a RightScale Environment, the system must be a
RightScale managed VM to have the required access to the right_api_client
with proxy_mode for instance_tokens, the scope is now limited to
operational instances in the same cloud as the VM making the call.
Usage
To create a machine_tag
machine_tag "namespace:predicate=value" do action :create end
To delete a machine_tag
machine_tag "namespace:predicate=value" do action :delete end
To list tags in the VM
class Chef::Recipe include Chef::MachineTagHelper end tags = tag_list(node)
To search tags in the VM
class Chef::Recipe include Chef::MachineTagHelper end tags = tag_search(node, 'test:tag=foo foo:bar=* some:tag')
Attributes
-
node['machine_tag']['vagrant_tag_cache_dir']
- path to store the tag data for each server. Only used in Vagrant environments. This should match aconfig.vm.synced_folder
entry in your Vagrantfile fortag_search()
to work across VMs. See theVagrantfile
for an example.
Recipes
default
Installs the machine_tag gem.
Resource/Provider
machine_tag
A resource to create and delete machine_tags on a VM.
Actions
Actions | Description | Default |
---|---|---|
:create |
Creates a new machine_tag on the VM | yes |
:delete |
Deletes a machine_tag from the VM |
Attributes
Attribute | Description | Default Value | Required |
---|---|---|---|
name |
Name of the machine tag | yes |
Helpers
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 end
tag_search(node, query, options = {})
Returns an array of tag hashes for all servers in your environment that matches the query.
Parameters
Name | Description | Type |
---|---|---|
node |
the environment (Vagrant or RightScale) | Chef::Node |
query |
the tags to be queried. If this is passed as a String the tags must be space delimited. |
String , Array
|
options | optional parameters to the query | Hash |
tag_list(node)
Returns a tag hash for the current server.
Parameters
Name | Description | Type |
---|---|---|
node |
the environment (Vagrant or RightScale) | Chef::Node |
Author
Author:: RightScale, Inc. (cookbooks@rightscale.com)
machine_tag Cookbook CHANGELOG
This file is used to list changes made in each version of the machine_tag cookbook.
v2.0.3
- adding a matcher for cookbook test
v2.0.2
- adding in support for chef 12.18
v2.0.1
- pinning right_api_client to 1.6.2, because 1.6.3 requires json(2)
v2.0.0
- Add support for Chef 12
v1.2.1
- Only returns operational instances
- Only returns instances in the same cloud as the machine executing the call.
v1.2.0
- Added support for match_all and defaulting to false
v1.1.0
- Added support for RightLink 10
v1.0.9
- Fixed bug in run_rs_tag_util method not returning string output.
v1.0.8
- Network issues can cause
rs_tag
command to fail. Retries are done if command is initially unsuccessful.
v1.0.7
- Add testing for support of Ubuntu 14.04, CentOS 7.0, and RedHat Enterprise Linux 7.0.
v1.0.6
- Update tag validation regex. (#13)
- Update strainer gem version to 3.x
v1.0.5
- Update to test-kitchen 1.2.1 and use the new concurrency flag. (#12)
- Make the Vagrant tag support act like RightScale where machine tags are only unique by namespace and predicate. (#14)
v1.0.4
-
Chef::MachineTag.factory
now checks for existence ofrs_tag
utility to detect RightScale environment. (#10) - Document Ruby 1.9 support. (#7)
- Update
tag_search
documentation in README (#9)
v1.0.3
- Accommodate changes from machine_tag (v1.1.3) gem
- Add class methods in MachineTagHelper
v1.0.2
- Updated README
- Fix the already initialized constants warning
- Updated Vagrantfile to work with Vagrant 1.3.x
v1.0.1
- Fix for packaged cookbook on Chef community site (Pull Request #3)
v1.0.0
- Initial release
Collaborator Number Metric
2.0.4 passed this metric
Contributing File Metric
2.0.4 failed this metric
Failure: To pass this metric, your cookbook metadata must include a source url, the source url must be in the form of https://github.com/user/repo, and your repo must contain a CONTRIBUTING.md file
Foodcritic Metric
2.0.4 failed this metric
FC085: Resource using new_resource.updated_by_last_action to converge resource: machine_tag/libraries/provider_machine_tag.rb:47
FC085: Resource using new_resource.updated_by_last_action to converge resource: machine_tag/libraries/provider_machine_tag.rb:55
FC122: Use the build_essential resource instead of the recipe: machine_tag/recipes/default.rb:22
Run with Foodcritic Version 16.3.0 with tags metadata,correctness ~FC031 ~FC045 and failure tags any
No Binaries Metric
2.0.4 passed this metric
Testing File Metric
2.0.4 failed this metric
Failure: To pass this metric, your cookbook metadata must include a source url, the source url must be in the form of https://github.com/user/repo, and your repo must contain a TESTING.md file
Version Tag Metric
2.0.4 failed this metric
Failure: To pass this metric, your cookbook metadata must include a source url, the source url must be in the form of https://github.com/user/repo, and your repo must include a tag that matches this cookbook version number
2.0.4 passed this metric
2.0.4 failed this metric
Failure: To pass this metric, your cookbook metadata must include a source url, the source url must be in the form of https://github.com/user/repo, and your repo must contain a CONTRIBUTING.md file
Foodcritic Metric
2.0.4 failed this metric
FC085: Resource using new_resource.updated_by_last_action to converge resource: machine_tag/libraries/provider_machine_tag.rb:47
FC085: Resource using new_resource.updated_by_last_action to converge resource: machine_tag/libraries/provider_machine_tag.rb:55
FC122: Use the build_essential resource instead of the recipe: machine_tag/recipes/default.rb:22
Run with Foodcritic Version 16.3.0 with tags metadata,correctness ~FC031 ~FC045 and failure tags any
No Binaries Metric
2.0.4 passed this metric
Testing File Metric
2.0.4 failed this metric
Failure: To pass this metric, your cookbook metadata must include a source url, the source url must be in the form of https://github.com/user/repo, and your repo must contain a TESTING.md file
Version Tag Metric
2.0.4 failed this metric
Failure: To pass this metric, your cookbook metadata must include a source url, the source url must be in the form of https://github.com/user/repo, and your repo must include a tag that matches this cookbook version number
2.0.4 failed this metric
FC085: Resource using new_resource.updated_by_last_action to converge resource: machine_tag/libraries/provider_machine_tag.rb:55
FC122: Use the build_essential resource instead of the recipe: machine_tag/recipes/default.rb:22
Run with Foodcritic Version 16.3.0 with tags metadata,correctness ~FC031 ~FC045 and failure tags any
2.0.4 passed this metric
Testing File Metric
2.0.4 failed this metric
Failure: To pass this metric, your cookbook metadata must include a source url, the source url must be in the form of https://github.com/user/repo, and your repo must contain a TESTING.md file
Version Tag Metric
2.0.4 failed this metric
Failure: To pass this metric, your cookbook metadata must include a source url, the source url must be in the form of https://github.com/user/repo, and your repo must include a tag that matches this cookbook version number
2.0.4 failed this metric
2.0.4 failed this metric
Failure: To pass this metric, your cookbook metadata must include a source url, the source url must be in the form of https://github.com/user/repo, and your repo must include a tag that matches this cookbook version number