Walkthrough: Running Chef cookbooks from the TrueSight Server Automation console
This topic walks you through the process of running a Chef cookbook on a target server from the TrueSight Server Automation console. This topic includes the following sections:
Introduction
This topic is intended for system administrators.
The goal of this topic is to demonstrate how to use the TrueSight Server Automation console to deploy a Chef cookbook (and pre-requisites) to a server currently being managed by TrueSight Server Automation.
What does this walkthrough show?
This walkthrough includes two scenarios:
- In scenario 1, the administrator wants to deploy a Chef cookbook that installs Java and creates a license file to a development server in the environment. However, the target server does not have the Chef Agent installed. So, the administrator wants to install the Chef Solo Agent and run the cookbook.
- In the second scenario, the target server already has the Chef-Solo Agent installed, so the administrator just wants to run the Chef cookbook that installs Java and creates a license file.
What do I need to do before I get started?
- For these two walkthroughs, we have logged on as BLAdmin, the default superuser for TrueSight Server Automation.
- Ensure the necessary Chef files are available, including all databags, environments and other dependencies, such as Ruby. Add the files to the Depot in the Depot > Chef > Chef Content > Chef Accessories folder. For more information about Chef-solo, see the Chef online technical documentation.
- You also have to ensure that you have met the requirements described in Overview-and-requirements-for-the-Chef-integration.
Scenario 1: Install Chef-solo and run a cookbook on a target
In this scenario, the system administrator wants to execute a cookbook on a development machine that installs Java on the target and creates a webserver license file as well. But, the admin also needs to install the Chef-Solo Agent on the target server as well, as it has not been previously installed and is required to run the cookbook.
To do that, the admin uses the TrueSight Server Automation console to bundle the Chef-Solo Agent install files and import them into the Depot, and then to import the Chef cookbook, as well as any dependent files for the cookbook.
| Step | Example screen |
---|---|---|
1 | In the console, select Actions > Chef > Create Chef Agent Bundle. | |
2 | Select the location of Chef Solo Agent installer file on the Select Chef Agent Installable Sources dialog box and click OK to import the Chef Solo installer. The Create Chef Agent Bundle General dialog box is displayed. | |
3 |
| |
4 | Completing this wizard automatically executes the Chef Packager Script Job NSH script job, as you can see in the Tasks in progress pane. This job creates several artifacts in the console folders:
| |
5 | Import the JSON files for Chef Data Bags, Role and Environments to the corresponding Depot folders under Chef > ChefContent > ChefAccessories. To add a file to a folder:
| |
6 | Next, we need to add the cookbook to the Depot. Select Actions > Chef > Create Cookbook Bundle. | |
7 | Next, you need to import the Chef cookbook, roles, environment, and databags.
Note: If desired, you can import an individual recipe instead of the whole cookbook. | |
8 |
|
|
9 | Completing this wizard executes the Chef Cookbook2BlPkgScript Job, as shown in the Tasks in progress bar to the right. This job creates several artifacts in the console folders:
| Depot folder Job folder |
10 | The next step is to execute the batch job (shown in the example to the right) against the target on which you want to install Chef Solo and run the Chef Cookbook.
The Batch Job copies and installs Chef-solo and Ruby on the target if the target does not have them already installed. It then deploys the cookbooks to the target and executes them through the Chef-solo Agent. You can evaluate the results of the Batch Job run and the Deploy Job run to see the status of the cookbook deployment. | |
11 | Verify that the cookbook was successfully executed on the target. For example, using the command line in the figure to the right indicates that both Java and the license file have been installed. |
Scenario 2: Executing a Chef cookbook on a target
In this scenario, the Chef-Solo agent is already installed on the target server, so we just want to run the cookbook to install java and create the license file.
| Step | Example screen |
---|---|---|
1 | Import the JSON files for Chef Data Bags, Role and Environments to the corresponding Depot folders under Chef > ChefContent > ChefAccessories. To add a file to a folder:
| |
2 | Next, we need to add the cookbook to the Depot. Select Actions > Chef > Create Cookbook Bundle. | |
3 | Next, you need to import the Chef cookbook, roles, environment, and databags.
Note: If desired, you can import an individual recipe instead of the whole cookbook. | |
4 |
|
|
5 | Completing this wizard executes the Chef Cookbook2BlPkgScript Job, as shown in the Tasks in progress bar to the right. This job creates several artifacts in the console folders:
| Depot folder Job folder |
6 | Run the Deploy Job created in the previous step to execute the Chef cookbook on the target development server. This job deploys the cookbook to the target and executes it through the Chef-solo Agent. You can evaluate the results of the Deploy Job run to see the status of the cookbook deployment. | |
7 | Verify that Java was installed and the license file created on the target. |
Wrapping it up
Congratulations! You have now used the out of the box Chef integration to run a Chef cookbook on a target server from the console.
Where to go from here
If you run into issues, see Troubleshooting-issues-with-the-Chef-integration.
You can also execute Chef scripts from the command line.