knife-exec1
The man page for the knife exec subcommand. the knife exec subcommand uses the knife configuration file to execute ruby scripts in the context of a fully configured chef-client. this subcommand is most often used to run scripts that will only access chef server one time (or otherwise very infrequently). use this subcommand any time that an operation does not warrant full usage of the knife subcommand library. authenticated api requests the knife exec subcommand can be used to make authenticated api requests to the chef server using the following methods: these methods are used with the -e option, which executes that string locally on the workstation using chef-shell. these methods have the following syntax: where: for example, to get the data for a node named "example_node": and to ensure that the output is visible in the console, add the puts in front of the api authorization request: where puts is the shorter version of the $stdout.puts predefined variable in ruby. the following example shows how to add a client named "ibm305ramac" and the /clients endpoint, and then return the private key for that user in the console: syntax this subcommand has the following syntax: options this subcommand has the following options: examples there are three ways to use knife exec to run ruby script files. for example: or: or: to check the status of knife using a ruby script named status.rb (which looks like): and is located in a directory named scripts/, enter: to show the available free memory for all nodes, enter: to list all of the available search indexes, enter: to query a node for multiple attributes using a ruby script named search_attributes.rb (which looks like): enter: to return something like:
History
- Debian 10 (Buster) to Debian 9 (Stretch): the text shown here
- Debian 8 (Jessie)
- Debian 7 (Wheezy)