Executing Chef scripts from the command line
This topic explains how to execute the Chef integration scripts from the command line. It includes the following sections:
Cookbook2BlPkg.nsh script
Use the Cookbook2BlPkg.nsh NSH script to create the required TrueSight Server Automation objects (BLPackages, Deploy Jobs, and so on) for the cookbook.
This script has following syntax:
[‑h <managedHost>]
‑c <cookbookfile1.gar.gzLocation>[,<cookbookfile2.tar.gzLocation> ...]
‑b <databagfile1.jsonLocation>[,<databagfile2.jsonLocation> ...]
‑e <environmentfile1.jsonLocation>[,<environmentfile2.jsonLocation> ...]
‑r <rolefile1.jsonLocation>[,<rolefile2.jsonLocation> ...]
‑d <dataBagName>
- node.jsonLocation specifies the file name and patch to the node.json file, which
- managedHost specifies the name of a TrueSight Server Automation managed host, which is required for creating jobs. This host is used temporarily only for job creation and is not retained as a job target, so it can be any managed host. If you do not specify this parameter, the script uses the string localhost. If a target with the name localhost is not a TrueSight Server Automation managed host, the script fails to run.
- cookbookfile specifies the full path and file name of the cookbook file(s).
- databagfile specifies the full path and file name of any databag item files used by the cookbook.
- environmentfile specifies the full path and file name of the environment file used to further classify the server, such as a test system, or a development system.
- rolefile specifies the full path and file name of the role file used to describe what a specific machine is supposed to do, such as a webserver or database server.
- databagname specifies a name for the databag.
Executing this script creates several artifacts:
- A Depot folder named CookBooks under the Chef > ChefContent folder. This folder has a sub folder with the name of the cookbook you imported. The sub folder contains the node.json file, .the tar.gz file, and the BLPackage that was created for the cookbook.
- Jobs folder named CookBooks under the Chef > ChefContent folder. This folder has a sub folder with the name of the cookbook you imported. The sub folder contains a Deploy Job for the cookbook. The sub-folder also has a Batch Job which contains the Deploy Job for both the Chef-Solo Agent and Chef Cookbook.
ChefPackagerScript.nsh script
Use the ChefPackagerScript NSH script to create the Chef Agent bundle and the Chef Agent deploy job
This script has following syntax:
‑v <OSVersion>
‑a <OSarchitecture>
‑r <rubyInstallerLocation>
‑c <chefVersion>
‑i <chefInstallerLocation>
‑d <dependencyFilesLocation>
‑t <fileTypeLocation>
<targets>
- OSName specifies the OS of the target server on which you want to install the Chef-solo Agent and Ruby. Enter RHEL or Ubuntu.
- OSVersion specifies the OS version of the target server on which you want to install the Chef-solo Agent and Ruby. For example, 10.2.
- OSarchitecture specifies the OS architecture type of the target server on which you want to install the Chef-solo Agent and Ruby. For example, 32-bit or 64-bit.
- rubyInstallerLocation specifies the full path and file name of the Ruby installer.
- chefVersion specifies the version of the Chef Agent you want to install. For example, 1.2.1.
- chefInstallerLocation specifies the full path and file name of the Chef installer.
- dependencyFilesLocation specifies the full path and file name of any dependency files required for the Chef Agent and Ruby installables..
- fileTypeLocation <Reviewers: what is this option for?>
- Targets specifies the name of a TrueSight Server Automation managed system, on which you want to install the Chef-solo Agent and Ruby installables.
When executed, this script creates several artifacts in the console folders:
- A Depot folder named Agent under the Chef > ChefContent Depot folder. This folder has all installers that you just uploaded as well as a BLPackage for the Chef-solo Agent and Ruby installables.
- A Jobs folder named Agent under the Chef > ChefContent Job folder. This folder has the deploy job for deploying the Chef-Solo Agent and Ruby installers.
ChefDeploy.nsh script
The ChefDeploy NSH script is used by the Chef agent Deploy Job and the Chef cookbook Deploy Job and is automatically executed when those Deploy Jobs are executed.
This NSH Script job installs the Ruby and Chef packages, which are created by the chefpackager.nsh script, on the target if they are not installed already. The Deploy Job also runs the cookbook(s). You can modify the version of Chef to be used by modifying the ChefVersion parameter of this NSH Script Job.