Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Knife plugin to copy a role into a new one

branch: master
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

Something went wrong with that request. Please try again.