We have a testing environment that consists of one server, one client and another client as workstation.
I am aware of the command
# knife cookbook site install apache2
but this command generates an error because I cannot even download using the cookbook site. When I download,
# knife cookbook site download apache2
this comes out,
ERROR: Connection refused connecting to cookbooks.opscode.com:80 for /api/v1/cookbooks/apache2, retry 1/5
ERROR: Network Error: Connection refused - Connection refused connecting to cookbooks.opscode.com:80 for /api/v1/cookbooks/apache2, giving up
Check your knife configuration and network settings
If you have something to solve this issue, please also share but my main issue is to know a way to install a cookbook manually? Not from the cookbook site? I tried downloading it from the site using the 'Download' button there and then copying the tar.gz to the workstation, uploading it to the chef server, adding the cookbook to the node's runlist recipe and then executing
# chef-client
in the workstation. Is this the same way as installing it? If not, is there a way to do it?
Thank you.
To upload a specific cookbook, go to the chef-repo directory, specify the cookbook name along with the cookbook directory as shown below. This will upload prod-db cookbook from local machine to the Chef Server. Please note that this will do the upload only if anything is changed in the cookbook locally.
In that case, use the -f option (or –force) to download the cookbook and overwrite the local directory with the version that was downloaded from the Chef server. Instead of downloading it under the current directory, you can also specify a download directory using -d option (or –dir option).
What is the difference between these two commands, and why are there two of them ? knife cookbook: The knife cookbook subcommand is used to interact with cookbooks that are located on the Chef server or the local chef-repo. chef generate cookbook: The chef generate cookbook subcommand is used to generate a cookbook.
The normal steps for uploading a cookbook from within your chef-repo is:
chef-repo/cookbooks
directoryknife cookbook upload -a
or knife cookbook upload [COOKBOOKS...]
chef-client
This seems to match what you did.
"Installing" a cookbook using knife cookbook site install COOKBOOK
is essentially the same as downloading it via knife cookbook site download COOKBOOK
except that the download command saves it as a .tar.gz whereas the install command extracts it and sets up a git submodule so that you can keep it up to date. (See Managing Cookbooks With Knife - Cookbook Site.)
You can use tools like Librarian or Berkshelf to manage and download cookbooks from any git repo, the Opscode community site, or a local path. Both of these gems work very similarly to Bundler; they generate a Cheffile.lock
or Berksfile.lock
which helps you lock cookbooks to a version or commit SHA.
EDIT: I'm not really sure why knife cookbook site install/download
won't work, though; they don't require any sort of authentication. From the knife cookbook site
docs: "For commands that simply read from the cookbook site (such as download, search, install, and list) you do not need an account on community.opscode.com. For commands that write to the site you need an account on the community site."
It's worth noting that knife cookbook site download
differs from knife cookbook download
. The former connects to community.opscode.com, while the latter connects to your chef server. Which are you having trouble with?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With