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.
$ 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/
Help output
$ knife role copy
USAGE: knife role copy ROLE NEW_ROLE (options)
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": {
}
}
LOLJK