Config.rb Configuration
The knife-opc plugin's subcommands, in contrast to other knife subcommands, make API calls to the root endpoint of your Chef Infra Server installation.
Typical chef_server_url for your chef infra Server looks like this:
chef_server_url 'https://chef.yourdomain.com/organizations/ORG_NAME'
Set the chef server root parameter to the root of your Chef Infra Server installation to setup knife-opc:
chef_server_root 'https://chef.yourdomain.com/'
This parameter defaults to https://chef.yourdomain.com/ if your chef_server_url configuration ends with /organizations/ORG NAME (as demonstrated above).
Standard Knife Opc Subcommands
Opc user List (plugin_knife_opc-opc-user-list)
List every user who has access to your Chef Infra Server installation.
Syntax
The syntax is given below:
Knife opc user List
Options
This has the options given below:
To show corresponding URL’s
-w, –with-uri
Examples
knife opc user list
Ninja1
Ninja2
knife opc user list -w
Ninja1: https://chef-server.fqdn/users/ninja1
Ninja2: https://chef-server.fqdn/users/ninja2
Opc user show(plugin_knife_opc-opc-user-list)
It reveals a user's specifics in your Chef Infra Server installation.
Syntax
The syntax is given below:
knife opc user show USER_NAME
Options
This has the options given below:
Display the associations that the user is a part of.
-l, –with-uri
Examples
knife opc user show Ninja -l
display_name: Coding Ninja
email: Ninja@chef.io
first_name: Coding
last_name: Ninja
middle_name:
organizations: code
public_key: -----BEGIN PUBLIC KEY-----
[...]
-----END PUBLIC KEY-----
username: Coding
Opc user Create(plugin_knife_opc-opc-user-create)
It creates a fresh user for your installed Chef Infra Server. The reply will contain the user's private key.
Syntax
The syntax is given below:
knife opc user create USER_NAME FIRST_NAME [MIDDLE_NAME] LAST_NAME EMAIL PASSWORD (options)
Options
This has the options given below:
Instead of writing to STDOUT, write the private key to FILENAME.
-f FILENAME, --filename FILENAME
Examples
knife opc user create Ninja1 Ninja2 codingNinja@chef.io password
-----BEGIN RSA PRIVATE KEY-----
[...]
-----END RSA PRIVATE KEY-----
Opc user Delete
It removes the specified OPC user.
Syntax
The syntax is given below:
knife opc user delete USER_NAME [-d] [-R]
Options
This has the options given below:
Don't first disconnect the user.
-d, --no-disassociate-user
Try to remove the user from any org admin groups where they may be a member. if —no-disassociate-user is set, ignored.
-R, --remove-from-admin-groups
Examples
knife opc user deletes Ninja1
Do you want to delete the user Ninja1? (Y/N) Y
Checking organization memberships...
Deleting user Ninja1.
Opc user Edit
It opens $EDITOR so you can edit a user. The knife will update the specified Chef Infra Server user once editing is complete.
Syntax
The syntax is given below:
knife opc user edit USER_NAME
Options
There are no options available
Examples
EDITOR=ed knife opc user edit Ninja1
63
1%p
{
"username": "Coding,"
"email": "Coding@chef.io",
"display_name": "Coding Ninja",
"first_name": "Coding",
"last_name": "Ninja",
"middle_name": "",
"public_key": "-----BEGIN PUBLIC KEY-----\n[...]\n-----END PUBLIC KEY-----\n\n"
}
/email/s/chef.io/xyz.com/p
"email": "Coding@xyz.com",
643
Saved Coding.
knife opc user show Coding
display_name: Coding Ninja
email: Coding@xyz.io
first_name: Coding
last_name: Ninja
middle_name:
public_key: -----BEGIN PUBLIC KEY-----
[...]
-----END PUBLIC KEY-----
username: Coding
Opc user Password
It commands for controlling a user's password and authentication.
Syntax
The syntax is given below:
knife opc user password USER_NAME [PASSWORD | --enable_external_auth]
Note: To enable external authentication for this user, the final argument should either be a string to use as a password or —enable_external_auth in place of a password.
Options
There are no options available
Examples
knife opc user password Ninja new password
{"username"=>"Ninja", "email"=>"Ninja@opscode.com", "display_name"=>"Ninja Coding", "first_name"=>"Ninja", "last_name"=>"Coding", "middle_name"=>"", "public_key"=>"-----BEGIN PUBLIC KEY-----\n[...]\n-----END PUBLIC KEY-----\n\n", "password"=>"newpassword", "recovery_authentication_enabled"=>true}
Authentication info updated for Ninja.
Opc org list [plugin_knife_opc-opc-org-list]
It list all the organizations that are installed on your Chef Infra Server.
Syntax
The syntax is given below:
knife opc org list (options)
Options
This has the options given below:
To show the corresponding URL
-w, –with-uri
Show auto-generated hidden organisations.
-a, --all-orgs
Examples
knife opc org list -w -a
acme: https://chef-server.fqdn/organizations/acme
Opc org Show[plugin_knife_opc-opc-org-show]
It displays information about a certain organization in your Chef Infra Server setup.
Syntax
The syntax is given below:
knife opc org show ORG_NAME
Options
There are no options available
Examples
knife opc org show CodingNinja
full_name: CodingNinja
guid: cc9f9d0d4f6e7e35272e327e22e7affc
name: CodingNinja
Opc org create [plugin_knife_opc-opc-org-create]
A new Chef Infra Server organization has been created. The organization's validator client's private key is given back
Syntax
The syntax is given below:
knife opc org create ORG_NAME ORG_FULL_NAME (options)
Options
This has the options given below:
Instead of writing to STDOUT, write the private key to FILENAME.
-f FILENAME, --filename FILENAME
Associate USER_NAME with the organization after creation.
-a USER_NAME, --association_user USER_NAME
Examples
knife opc org create Ninja2"The Other Ninja" -a Ninja1
-----BEGIN RSA PRIVATE KEY-----
[...]
-----BEGIN RSA PRIVATE KEY-----
Opc org delete [plugin_knife_opc-opc-org-delete]
The specified Chef Infra Server organization is deleted.
Syntax
The syntax is given below:
knife opc org delete ORG_NAME
Options
No options available.
Examples
knife opc org delete Ninja2
Do you want to delete the organization Ninja2? (Y/N) Y
full_name: The Other Ninja
guid: 2adec1140cf777a15d82d9099304da71
name: Ninja2
Opc org user add
It adds a user to a company and demands the existence of the named user and the organization.
Syntax
The syntax is given below:
knife opc org user add ORG_NAME USER_NAME
Options
No options available.
Examples
knife opc org user add CodingNinja ninja1
Opc org user Remove
It expels a user from a company and requires the existence of the named user, the named organisation, and that the user is currently connected to the organisation.
Syntax
The syntax is given below:
knife opc org user remove ORG_NAME USER_NAME
Options
No options available.
Examples
knife opc org user remove CodingNinja ninja1
Frequently Asked Questions
What is a Knife in a chef?
A knife is a command-line tool that connects the Chef Infra Server and a local chef-repo.
How do you run a chef's knife command?
knife commands: | by Venkata Chitturi | DevOps Process and Tools | Medium. chef-client — command to run on a node called convergence. Knife environment compares — all -to compare all recipes in the server across all environments. Knife environment show dev — shows environment information.
What are the three main components of a Chef?
Workstations, servers, and nodes are the three main components of Chef.
What do you mean by a client in Chef?
On each node that Chef is responsible for managing, an agent called a chef-client runs locally.
What do you understand about a node in Chef?
A node is a machine or system managed by the Chef server. It can be attached to any network that can send and receive information.
Conclusion
This article has extensively discussed the knife Opc subcommand, its properties, and syntax.
Refer to our guided paths on Coding Ninjas Studio to learn more about DSA, Competitive Programming, JavaScript, System Design, etc. Enrol in our courses and refer to the mock test and problems available; look at the Top 150 Interview Puzzles, interview experiences, and interview bundle for placement preparations. Read our blogs on aptitude, competitive programming, interview questions, IT certifications, and data structures and algorithms for the best practice.
Happy Coding.