Use > Get started with Chef Cookbooks in SA > Chef management > Use Chef Cookbooks and Recipes in SA

Use and manage Chef Cookbooks and Recipes

This section describes how to use and manage Chef Cookbooks and Recipes in SA.

Note
HPE does not provide Chef content. The Chef Cookbooks can be downloaded from the Chef Community portal, any other source provider, or can be created by software developers. See the Opscode documentation for explanations about Chef content and framework: https://docs.chef.io/

Uploading Chef Cookbooks to SA

SA supports uploading Chef Cookbooks to SA the same way you would import any software package. You can import from the SA Client or from the SA Command Line Interface (CLI).

Importing a Chef Cookbook from the SA Client

Importing cookbooks in the SA Client is the same process as importing other packages. It is important to select “Chef Cookbook” file type during the import.

To import a Chef Cookbook from the SA Client:

  1. Find and select the desired import destination for the Chef Cookbook using one of the following methods. All of these methods start from the Library tab in the SA Client:
    1. Method 1: Library > By Type > Chef Cookbooks.
      1. Find and open the operating system where the Chef Cookbook(s) should be imported.
      2. Select Actions > Import Cookbook…
    2. Method 2: Library > By Type > Packages.
      1. Find and open the operating system where the Chef Cookbook(s) should be imported.
      2. Select Actions > Import Software…
    3. Method 3: Library > By Folder.
      1. Find and open the folder in which the Chef Cookbook(s) should be imported.
      2. Select Actions > Import Software…
  2. In the File(s) section of the Software Imports window:
    1. Click Browse to locate the Chef Cookbook(s) to import.
    2. Select the cookbook(s) to import.

      Character encoding is not relevant because cookbooks are binary files.
    3. Click Open.
    4. Select Chef Cookbook (tgz archive) file type from the Type drop-down list:


  3. In the Folder section of the Software Imports window, click Browse to select the destination folder location.
  4. From the Platform drop-down list, select the applicable operating systems or operating system families.

    Best Practice: Associate a cookbook with the supported platforms defined by the cookbook metadata. The platform associations for Chef Cookbooks are only guidelines as SA mirrors the behavior of Chef and will run the Recipe on any chosen server.
    When viewing cookbooks on the Chef Community portal (https://supermarket.chef.io/), the supported platforms are indicated on the download page and in the cookbook metadata file (metadata.rb). To view the cookbook metadata in SA, see Viewing cookbook details in SA Client.

  5. Click Import.
  6. (Optional) If one of the packages you are importing already exists in the folder, you will be prompted with the following options for handling the duplicate file:
    • Replace: Replace (overwrite) the contents of the existing file.
    • Replace All: When there are multiple existing files with the same name as the file you are importing, you can replace (overwrite) the contents of all the existing file.
    • Skip: Skip the replacement of a single file. If you have multiple existing files with the same name as the files you are importing, you can select which files to skip or not. Skipping the import of a file does not affect other files with different names if you are importing multiple files. Only the specified file(s) will be skipped, the other specified files will be imported.
    • Skip All: All specified files with the same name as the file you are importing will be skipped and not replaced.
    • Cancel: Cancels the Import Packages operation entirely. No files are imported.
    • Help: Provides online help for the current dialog.
  7. View the progress of the importing files in the Software Imports window while the import is underway, the Software Imports window displays the details and progress of the import. This window displays all the imports made within the session.


Upload Chef Cookbooks from the SA Command Line Interface (CLI)

Importing cookbooks via the SA CLI is the same process as importing other packages. It is important to specify “Chef Cookbook” file type during the import.

To perform SA CLI commands, your login must have the appropriate authorizations to run oupload or odownload. For information on permissions, see the SA Administering.

See the Using for additional details about SA CLI commands. See the Software Management for information specific to different package types.

The oupload command has the following syntax. The filenames can contain a relative or absolute local file or directory path. If an option value contains spaces, enclose the value in quotes.

oupload [options] filenames

To upload Chef Cookbooks from the SA Command Line Interface (CLI):

  1. To upload a Chef Cookbook, specify the package type, “Chef Cookbook” in quotes or just CHEF_COOKBOOK, without quotes.
    For example:

    [root@cbt1 ~]# /opt/opsware/ocli/ocli/bin/oupload.sh --os "Red Hat Enterprise Linux Server 6" --pkgtype "Chef Cookbook" --folder "Package Repository" ./ntp20131006.tar.gz

    Where, ./ntp20131006.tar.gz is the local relative path to the cookbook you are uploading to the SA folder “Package Repository.” In this example, the command is performed from one of the SA Core servers.

  2. When prompted, enter the username and password of an SA user with the appropriate authorizations.
  3. If the file already exists, in the specified location, you will be prompted with the option to overwrite the file. Enter “y” to overwrite it or “n” to cancel the action:

    ntp20131006.tar.gz already exists. overwrite? [y,n]: y

  4. “COMPLETE” will appear on the command line to notify you when the process is complete:

    Package Repository/./ntp20131006.tar.gz: COMPLETE
    [root@core-20 install_opsware]#

Cookbook versioning

SA stores cookbooks in a folder-like structure and this allows users to upload the same cookbook (name and version) several times by placing it in different folders or in the same folder but with different SA filenames.

In such a case, it is undefined which exact instance of the cookbook will be used at runtime. This will not cause any issues as long as users follow the basic principle that two cookbooks having the same names and versions are identical.