Managing roles
There are multiple ways to manage roles in the Chef ecosystem.
Using Knife
Knife can be used to create, edit, delete, edit, or show a particular role; alternatively, it can be used to push a role file created using Ruby DSL to the Chef server. Knife can also be used to get a list of all roles defined on the Chef server.
Creating a new role
The knife role create ROLE
command can be used to create a new role. Let's use it to create a role called webserver
and see the command in action:
$ knife role create webserver
As soon as you issue this command, an editor will open up. The choice of which editor to make use of can be specified by editing the value of the knife[:editor]
attribute in your knife.rb
file.
The file will look like the following:
{ "name": "webserver", "description": "", "json_class": "Chef::Role", "default_attributes": { }, "override_attributes": { }, "chef_type": "role", "run_list": [ ], "env_run_list": [ ] }
This is a simple JSON...