knife-role - Online in the Cloud

This is the command knife-role that can be run in the OnWorks free hosting provider using one of our multiple free online workstations such as Ubuntu Online, Fedora Online, Windows online emulator or MAC OS online emulator

PROGRAM:

NAME


knife-role - The man page for the knife role subcommand.

A role is a way to define certain patterns and processes that exist across nodes in an
organization as belonging to a single job function. Each role consists of zero (or more)
attributes and a run-list. Each node can have zero (or more) roles assigned to it. When a
role is run against a node, the configuration details of that node are compared against
the attributes of the role, and then the contents of that role's run-list are applied to
the node's configuration details. When a chef-client runs, it merges its own attributes
and run-lists with those contained within each assigned role.

The knife role subcommand is used to manage the roles that are associated with one or more
nodes on a Chef server.

COMMON OPTIONS


The following options may be used with any of the arguments available to the knife role
subcommand:

--chef-zero-port PORT
The port on which chef-zero will listen.

-c CONFIG_FILE, --config CONFIG_FILE
The configuration file to use.

-d, --disable-editing
Use to prevent the $EDITOR from being opened and to accept data as-is.

--defaults
Use to have knife use the default value instead of asking a user to provide one.

-e EDITOR, --editor EDITOR
The $EDITOR that is used for all interactive commands.

-E ENVIRONMENT, --environment ENVIRONMENT
The name of the environment. When this option is added to a command, the command
will run only against the named environment.

-F FORMAT, --format FORMAT
The output format: summary (default), text, json, yaml, and pp.

-h, --help
Shows help for the command.

-k KEY, --key KEY
The private key that knife will use to sign requests made by the API client to the
Chef server.

--[no-]color
Use to view colored output.

--print-after
Use to show data after a destructive operation.

-s URL, --server-url URL
The URL for the Chef server.

-u USER, --user USER
The user name used by knife to sign requests made by the API client to the Chef
server. Authentication will fail if the user name does not match the private key.

-V, --verbose
Set for more verbose outputs. Use -VV for maximum verbosity.

-v, --version
The version of the chef-client.

-y, --yes
Use to respond to all confirmation prompts with "Yes". knife will not ask for
confirmation.

-z, --local-mode
Use to run the chef-client in local mode. This allows all commands that work
against the Chef server to also work against the local chef-repo.

BULK DELETE


The bulk delete argument is used to delete one or more roles that match a pattern defined
by a regular expression. The regular expression must be within quotes and not be
surrounded by forward slashes (/).

Syntax

This argument has the following syntax:

$ knife role bulk delete REGEX

Options

This command does not have any specific options.

Examples

Use a regular expression to define the pattern used to bulk delete roles:

$ knife role bulk delete "^[0-9]{3}$"

CREATE


The create argument is used to add a role to the Chef server. Role data is saved as JSON
on the Chef server.

Syntax

This argument has the following syntax:

$ knife role create ROLE_NAME (options)

Options

This argument has the following options:

-d DESCRIPTION, --description DESCRIPTION
The description of the role. This value will populate the description field for the
role on the Chef server.

Examples

To add a role named role1, enter:

$ knife role create role1

In the $EDITOR enter the role data in JSON:

## sample:
{
"name": "role1",
"default_attributes": {
},
"json_class": "Chef::Role",
"run_list": ['recipe[cookbook_name::recipe_name],
role[role_name]'
],
"description": "",
"chef_type": "role",
"override_attributes": {
}
}

When finished, save it.

DELETE


The delete argument is used to delete a role from the Chef server.

Syntax

This argument has the following syntax:

$ knife role delete ROLE_NAME

Options

This command does not have any specific options.

Examples

$ knife role delete devops

Type Y to confirm a deletion.

EDIT


The edit argument is used to edit role details on the Chef server.

Syntax

This argument has the following syntax:

$ knife role edit ROLE_NAME

Options

This command does not have any specific options.

Examples

To edit the data for a role named role1, enter:

$ knife role edit role1

Update the role data in JSON:

## sample:
{
"name": "role1",
"default_attributes": {
},
"json_class": "Chef::Role",
"run_list": ['recipe[cookbook_name::recipe_name],
role[role_name]'
],
"description": "This is the description for the role1 role.",
"chef_type": "role",
"override_attributes": {
}
}

When finished, save it.

FROM FILE


The from file argument is used to create a role using existing JSON data as a template.

Syntax

This argument has the following syntax:

$ knife role from file FILE

Options

This command does not have any specific options.

Examples

To view role details based on the values contained in a JSON file:

$ knife role from file "path to JSON file"

LIST


The list argument is used to view a list of roles that are currently available on the Chef
server.

Syntax

This argument has the following syntax:

$ knife role list

Options

This argument has the following options:

-w, --with-uri
Use to show the corresponding URIs.

Examples

To view a list of roles on the Chef server and display the URI for each role returned,
enter:

$ knife role list -w

SHOW


The show argument is used to view the details of a role.

Syntax

This argument has the following syntax:

$ knife role show ROLE_NAME

Options

This argument has the following options:

-a ATTR, --attribute ATTR
The attribute (or attributes) to show.

Examples

To view information in JSON format, use the -F common option as part of the command like
this:

$ knife role show devops -F json

Other formats available include text, yaml, and pp.

To view information in JSON format, use the -F common option as part of the command like
this:

$ knife role show devops -F json

Other formats available include text, yaml, and pp.

Use knife-role online using onworks.net services



Latest Linux & Windows online programs