Launching a job template

The Launch a Job Template action launches a specified job template from the Ansible Tower server. This template contains actions that are executed when the template is launched. For example, a template can contain action to stop an Amazon EC2 instance.

You specify this action while creating a policy. 

While creating an action, you can use an event stored in the BMC Helix Intelligent Automation database or provide an event in a JSON format. 

Important

The process described in this topic is for one of the Ansible Tower actions supported by BMC Helix Intelligent Automation. Use the steps in this topic to add any Ansible Tower actions while creating a policy.

Before you begin

Do the following steps to include event attributes in the Ansible Tower's job or workflow template: 

  1. Log on to Ansible Tower.
  2. Go to the Resources > Templates section and open the job template or the workflow template that you want to launch via the automation policy.
  3. In the EXTRA VARIABLES section, include the variables and their values as per the template requirements.
    For example, if a template contains the action to stop an EC2 instance, specify the instance ID and the region for the instance in the following format:

    {
            "instance_ids": [
                "i-0bb9cc75035405998"
            ],
            "region": "us-east-1"
        }
    }

    Note

    The extra variables in the request body (specified while adding an action) get overridden in Ansible Tower only if the Prompt on Launch option is enabled in Ansible Tower.

    For more information about the job templates and extra variables, see the Ansible Tower documentation. 

To add Launch a Job Template action to a policy

  1. In the BMC Helix Intelligent Automation console, click Policies and the click Create Automation Policy.
  2. In the Policy Information section, enter a unique name and an optional description for the policy. 
  3. Select Manual or Automatic depending upon whether you want to execute the policy manually or automatically based on the incoming events.
  4. In the Trigger section, click Browse and perform one of the following steps to select an event:
    • From the Select Event Type tab, select an existing event type, and click Done.
    • On the Paste Event JSON tab, enter event in the JSON format, and click Done.

      Sample event for launching a job template
      "tags": {
          "event_type": "STOP_EC2_INSTANCE",
          "region": "ap-southwest",
          "instance_ids": ["i-05rab782b1f3770ct"]
              }

      The event contains the following details:

      • region is the location in which the instance to be shut down is located.

      • instance_ids is the ID for the instance that you want to stop.

  5. In the Trigger Condition text box, build the following expression to match the trigger condition to the event:

    ( tags.event_type == STOP_EC2_INSTANCE ) && ( tags.event.region == ap-southwest ) && ( tags.event.instance_ids == i-05rab782b1f3770ct )

    To understand the expression syntax, see the Trigger condition expressions section in Creating automation policies.

  6. To add system or custom tags to the policy, perform the following steps:
    1. System tags: Select one or more tags from the list of available system tags. 
      Based on the event, some system tags are displayed.
    2. Custom tags: In the Tags (Optional) section, enter a key-value pair. 
      Tag key should start with an alphabet and end with an alphanumeric character. Key supports alphanumeric characters and periods, dashes, and underscores. 
  7. To add action to the policy, click Add Action and perform the following steps by using the action wizard:
    1. From the Pick an automation tool section, click the connector name.
      Only configured connectors are displayed here. The wizard takes you to the next step to select an action. 
    2. Click Sync Actions
      All job template and workflow template actions in your Ansible Tower instance appear. 
    3. Click Select against the Launch a Job Template action.
      The wizard takes you to the next step to configure an action.
    4. Provide the following information:
      1. In Request body, enter the region and instance ID in the following format:

        Sample request body for stopping an AWS EC2 instance
        {
            "extra_vars": {
                "instance_ids": [
                    "i-0bb9cc75035405998"
                ],
                "region": "us-east-1"
            }
        }

        Replace <region> with the region in which the instance ID is located and instanceID with the ID of the instance that you want to stop by launching this template. The <region> and <instanceID> variables should match the variables in the Ansible template.

      2. In Template Id, enter the ID of the template that you want to launch. 
      3. Note

        Based on the selected event, the event slots with the values specified in the event appear under the Parameters section on the UI. You can click any of the parameters and its value gets copied. You can paste it while defining the action in the policy. 

    5. Click Done.
      The added action appears in the Action Configuration section on the Create Automation Policies page.
  8. In the Estimated Savings section, enter an approximate time (in minutes) and money (in USD) that you may save by automating this action.
  9. Select Publish Policy and click Save to publish the policy.

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

Comments