Knife plugin to copy a role into a new one
Ruby
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
README.md Quick install and help output. Dec 2, 2011
role_copy.rb

README.md

ROLE COPY

Get data from one role, setup a new role with that data and a new name.

This plugin will actively refuse to create a role with a name that already exists.

INSTALL

$ git clone git@github.com:benjaminws/knife_role_copy.git
$ mkdir -p ~/.chef/plugins/knife/
$ cp knife_role_copy/role_copy.rb ~/.chef/plugins/knife/

USAGE

Help output

$ knife role copy
USAGE: knife role copy ROLE NEW_ROLE (options)

EXAMPLE

Take a look at this role.

$ knife role show -Fj test_role
{
  "name": "test_role",
  "default_attributes": {
    "your": "mom"
  },
  "json_class": "Chef::Role",
  "env_run_lists": {
  },
  "run_list": [
    "recipe[fun_recipe]"
  ],
  "description": "THIS IS A TEST ROLE, LOL",
  "chef_type": "role",
  "override_attributes": {
  }
}

Now copy it.

$ knife role copy test_role test_role_copy
# DROPS YOU INTO $EDITOR
# EDIT TO YOUR HEARTS CONTENT

Magic happens.

$ knife role show -Fj test_role_copy
{
  "name": "test_role_copy",
  "default_attributes": {
    "your": "mom"
  },
  "json_class": "Chef::Role",
  "env_run_lists": {
  },
  "run_list": [
    "recipe[fun_recipe]"
  ],
  "description": "THIS IS A TEST ROLE, LOL (Copy from test_role)",
  "chef_type": "role",
  "override_attributes": {
  }
}

NOTE

LOLJK