Unsupported content

   

This version of the documentation is no longer supported. However, the documentation is available for your convenience. You will not be able to leave comments.

Chef field kit samples

This topic contains examples of executing Chef cookbooks by using the Chef field kit.

Apache installation recipe

Recipe: apache2 (1.6.2)

Cookbook download link: http://community.opscode.com/cookbooks/apache2

To execute the Apache installation cookbook

  1. Run the following blchef.rb script to download the apache2 cookbook from cookbooks.opscode.com:

    ruby blchef.rb apache2

    The command output looks similar to the following:

    SUCCESS: Created
    bundle staging/apache2.tar.gz and file staging/node.json
    
    To create a BSA Orchestration Bundle (a.k.a. BlPackage) execute command:
    
    nsh cookbook2blpkg.nsh -p <Package Name> -n staging/node.json -c
    staging/apache2.tar.gz
    
    Review/Edit the staging/node.json to ensure the use of desired attributes and
    recipes.

    Successful execution of the script produces the following files: 

    • apache2.tar.gz: Contains the cookbook and its dependencies
    • node.json: Contains cookbooks and attributes
  2. Edit the node.json file as required. The following example shows sample parameters from a node.json file:

    "normal":
    {
        "apache": {
          "dir":
    "/etc/apache2",
          "log_dir":
    "/etc/apache2",
          "user":
    "www-data",
          "binary":
    "/usr/sbin/apache2",
          "icondir":
    "/usr/share/apache2/icons",
          "listen_ports": 
        [
            "80",
            "443"     ],
  3. Use the following command to create BMC Server Automation objects (BLPackages and Deploy Jobs) to deploy the cookbook on the required host:

    nsh
    cookbook2blpkg.nsh -p apache2 -n staging/node.json 
    
    -c staging/apache2.tar.gz -h <hostName>

    The following example shows a few sample lines from the command output: 

    Created
    Job group /Chef/apache2_GROUP
    Created a deploy job named dj_apache2 in job group /Chef/apache2_GROUP
    Create a batch job named batch_job_apache2 in /Chef/apache2_GROUP

    Note

    The version of the apache2 cookbook downloaded had a problem: the site was not enabled. To resolve the issue, a job named job_httpd_reload was created in BMC Server Automation to enable the site, the http service was reloaded, and the job was added to the Batch Job named batch_job_apache2, as shown in the following figure:

MySQL installation recipe

Recipe: mysql (3.0.2)

Cookbook download link: http://community.opscode.com/cookbooks/mysql

To execute the MySQL installation cookbook

  1. Run the following blchef.rb script to download the mysql cookbook from the cookbooks.opscode.com:

    ruby blchef.rb mysql

    The following example shows a few sample lines from the command output:

    SUCCESS:
    Created bundle staging/mysql.tar.gz and file staging/node.json
    To create a BSA Orchestration Bundle (a.k.a. BlPackage) execute command:
    nsh cookbook2blpkg.nsh -p <Package Name> -n staging/node.json -c
    staging/mysql.tar.gz
    Review/Edit the staging/node.json to ensure the use of desired attributes and
    recipes.

    Successful execution of the script produces the following files:

    • mysql.tar.gz: Contains the cookbook and its dependencies
    • node.json: Contains recipes and attributes
  2. Edit the node.json file, as required.

    The following example shows how to modify install the non-default recipe mysql server recipe recipe[mysql::server] to be installed on server nodes by modifying the default node recipe[mysql]:

    "run_list":
    [
        "recipe[openssl]",
        "recipe[build-essential]",
        "recipe[mysql::server]"
    ]
  3. Use the following command to create the BMC Server Automation objects (BLPackages and Deploy Jobs) to deploy the cookbook on the required hosts:

    nsh
    cookbook2blpkg.nsh -p mysql -n staging/node.json 
    
    -c staging/mysql.tar.gz -h <hostName>

    The following example shows a few sample lines from the command output:

    Created
    Job group /Chef/mysql_GROUP
    Created a deploy job named dj_mysql in job group /Chef/mysql_GROUP
    Create a batch job named batch_job_mysql in /Chef/mysql_GROUP

  

Was this page helpful? Yes No Submitting... Thank you

Comments