Chef integration example for Cloud Management

You can provision cloud resources based on resource types on your Chef server and manage newly provisioned resources through both the Chef Server and your ServiceNow instance.

Chef integration involves registering your Chef server to the instance, running Discovery, and creating customized blueprints and application profiles.

Requirements

  • Role required: cloud_admin
  • Install and configure a Chef server

What to do

Create a Chef server provider and run Discovery
First create a Chef server provider record with the necessary Chef credentials that can access the server. Then run Discovery on the Chef server to populate the CMDB. See Create a Chef server provider and run Discovery for instructions.
Create an application profile and template
Your users can select a virtual machine that is based on an application profile, which in turn is based on a Chef resource. You must map an application profile template to a cloud resource profile of type Application. See Example: create an application profile template for Chef integration and Create a cloud resource profile for instructions.
Create a blueprint
Create a new blueprint with BootstrapNode and ExecuteConfigPackages resource operations and customize the form to allow the user to select the application profile template, organization, and credential ID. See Example: create a blueprint for Chef integration for an example.

Next steps

After a user provisions a resource from the blueprint, the Stack Status indicates how the system runs through the Create node, Bootstrap, and ExecuteConfigPackage steps. You can obtain the IP address of a virtual machine in the User Portal by going to Stacks > {category} and selecting the new virtual machine. Open the Chef server to see the newly provisioned resource on the node the user specified.

Create a Chef server provider and run Discovery

Before you begin

Procedure

  1. Navigate to Cloud Config Management > Config Providers > Chef Server.
  2. Click New.
  3. Fill out the form fields (see table). Obtain most of this information from your Chef server etup.
    Field Description
    Name Enter a descriptive name.
    URL Enter the URL of your Chef server, including port number.
    Organization Enter the Chef organization for access control.
    Version Select a version.
    Server Type Select a server type.
    Service Category Select one of the Cloud Service categories.
    Provider Select Chef.
    Default Select if you want this Chef server to be the default.
    Credential Select the Chef credentials
  4. Right-click the header and select Update.
  5. Click Create Chef Discovery Schedule.
  6. Configure the schedule or click Discover Now.

Result

The Related Items list shows discovered resources. You can create application templates and application profiles from these so your users can order Chef-based resources.

Example: create an application profile template for Chef integration

Create an application profile template from discovered resources in a Chef server. You can use these to allow users to select the type of application profile when they provision a virtual machine.

Before you begin

Procedure

  1. Navigate to Cloud Config Management > Application Profile Template.
  2. Click New.
  3. Fill out the form fields (see table).
    Field Description
    Name Provide a descriptive name.
    Template ID Enter an ID to use for the template.
    Config Runlist Click the lookup icon and select Chef Roles [sn_cfg_chef_server_role] for the Table Name and choose the chef role for the Document field.
    Config runlist provider Select Chef Roles [sn_cfg_chef_server_role].
    Provider Instance Select the Chef server provider.
  4. Right-click the header and select Save.

Example: create a blueprint for Chef integration

This example shows you how to create a custom blueprint that you can use in a Chef integration.

Before you begin

Role required: cloud_admin

Procedure

  1. Navigate to Cloud Management > Cloud Service Design > Blueprints.
  2. Click New.
  3. Create a deployment model with a container, virtual machine, and a datacenter.

  4. Click the Operations tab, and then click Steps.
  5. Add these resource operations based on the Virtual Server:
    • Bootstrap Node
    • ExecuteConfigPackages

      Adding the bootstrap operation

    You should have four operations:
    • Blueprint Container Resource.Provision
    • Virtual Server.Provision
    • Bootstrap Node
    • ExecuteConfigPackages
  6. Make the following changes to these operations and click Save after each change:
    Operation Make this change
    Blueprint Container Resource.Provision Enable WorkloadConfigProvider. The user uses this field to select the Chef server.
    Bootstrap Node Enable CredentialId and Organization.
    ExecuteConfigPackages Enable ApplicationProfile to allow the user to choose the application resource profile that is based on the discovered resources in the Chef server. Also disable WorkloadConfigProvider since you already enabled it on the container.
  7. Create a form with a descriptive name, save it, and click Generate entities.
  8. On the Events related list, click FieldChange.
  9. Click New, name the rule ReloadOrganizationAndCredential, select the WorkloadConfigProvider for the Source field, and save the record.
  10. Create an action for the newly created FieldChange rule:
    Field Description
    Name Use something descriptive like Reload Virtual Server CredentialID.
    Action Type Select Reload.
    Datasource Select Reload from Pool to pull the possible values from a resource pool. By default, the Chef Server pool filters chef server credentials by Chef server.
    Target Field Enter Virtual_Server_CredentialID--the name of the catalog property that is automatically created for the blueprint. You can view it on the Catalog Properties related list of the form.
  11. Create a KeyValue record with both the Key and Value as WorkloadConfigProvider.
  12. Create another action for the FieldChange rule you created above, but name it Reload Virtual Server Organization and enter Virtual_Server_Organization for the Target Field. Also create a KeyValue record with both the Key and Value as WorkloadConfigProvider.
  13. Publish the catalog item and make it active.

Result

Your users can provision a resource based on this blueprint. See Chef integration example for Cloud Management for a high-level overview of what happens during an example Chef integration and provisioning.