How do I run the chef knife plugin?

264 Views Asked by At

I would like to use a knife plugin. e.g. KnifeSpork I got the plugin installed. But I get errors when I try to run it.

First try

Install KnifeSpork:

$ gem install knife-spork

Run KnifeSpork:

$ knife spork info

Output:

FATAL: Cannot find subcommand for: 'spork info'
Available subcommands: (for details, knife SUB-COMMAND --help)

** CHEF ORGANIZATION MANAGEMENT COMMANDS **
knife org create ORG_SHORT_NAME ORG_FULL_NAME (options)
knife org delete ORG_NAME
knife org edit ORG
knife org list
knife org show ORGNAME
knife org user add ORG_NAME USER_NAME
knife org user remove ORG_NAME USER_NAME
....

Second try

Create a Gemfile

source 'https://rubygems.org'

gem 'knife-spork'

Install the dependencies

$ bundle install

Run KnifeSpork:

$ bundle exec knife spork info

Output:

Could not find ffi-1.15.4, ffi-yajl-2.4.0, libyajl2-2.1.0, json-2.6.1 in any of the sources
Run `bundle install` to install missing gems.

Additional info

$ rvm -v
rvm 1.29.12-next (master) by Michal Papis, Piotr Kuczynski, Wayne E. Seguin [https://rvm.io]
$ ruby -v
ruby 2.7.4p191 (2021-07-07 revision a21a3b7d23) [x86_64-darwin20]
$ chef -v
Chef Workstation version: 21.11.679
Cookstyle version: 7.25.9
Chef Infra Client version: 17.7.29
Chef InSpec version: 4.49.0
Chef CLI version: 5.4.2
Chef Habitat version: 1.6.420
Test Kitchen version: 3.1.1
$ bundle show knife-spork
/Users/name/.rvm/gems/ruby-2.7.4/gems/knife-spork-1.7.3
$ bundle show json
/Users/aseitz/.rvm/gems/ruby-2.7.4/gems/json-2.6.1
1

There are 1 best solutions below

0
sschueller On

Here is how I was able to get spork installed on the latest version of chef-workstation (23.4) on a M2 mac.

Install Chef-workstation

brew install --cask chef-workstation

Add ruby to your path

echo 'export PATH="~/.chef/gem/ruby/3.1.0/bin:$PATH"' >> ~/.zshrc

Open new terminal window

Install spork

chef gem install knife-spork