Chapter 2. Invoking Automate

2.1. Automate Examples

This chapter describes the ways to invoke an Automate workflow. Automation can be initiated through an alert, an event, a Red Hat CloudForms application, or a custom button. The same automation process can be re-used across more than one of these. For example, using automation to remove orphaned virtual machines and instances could be initiated by:

  • An administrator request from the Red Hat CloudForms console (from a custom button)
  • An alert indicating the datastore has less than 20% free-space
  • A virtual machine or instance unregistered event is detected

All invocations of an automate model must enter through the /System/Process namespace.

2.2. Invoking Automate using a Custom Button

Invoke an Automate model by mapping an Ansible playbook or instance from the /System/Process/Request class to a custom button. Before creating the button, you need to have an Ansible playbook service catalog item or an instance in the /System/Process/Request class to map to it and a button group to assign it to.

Create buttons for a cluster, host, datastore, provider, virtual machines or cloud instances. When the button is clicked, the model or playbook will be invoked for the selected item. For each of these, you can have up to 15 buttons.

2.3. Creating a Custom Button Group

This procedure shows you how to create a custom button group.

  1. Navigate to AutomationAutomateCustomization.
  2. Click the Buttons accordion.
  3. From the Object Types tree, select the type of object you want to create the button group for.
  4. Click image (Configuration), image (Add a new Button Group).
  5. Type in a Button Group Text and Button Group Hover Text, and select the Button Group Image you want to use.
  6. If custom buttons have already been created, assign them to the button group. If not, see Section 2.4, “Creating a Custom Button” to create custom buttons.
  7. Click Add.

The button group will show in the object type you added the button to.

2.4. Creating a Custom Button

This procedure shows you how to create a custom button.

  1. Navigate to AutomationAutomateCustomization.
  2. Click the Buttons accordion.
  3. From the Object Types tree, select the type of object you want to create the button for.
  4. Click Unassigned Buttons.
  5. Click image (Configuration), then image (Add a new Button).

    Note

    If image (Add a new Button) is not available, that means you have not created a button group for that object. To continue, create a button group first. See Section 2.3, “Creating a Custom Button Group”

  6. In Action, type in a Button Text and Button Hover Text, and select the Button Image you want to use.
  7. Select a Dialog if applicable.
  8. In Object Details, select Request from the /System/Process/ dropdown. By default, the message is create. Do not change it.
  9. Type in a Request name for the /System/Process/Request instance.
  10. Type in the Attribute/Value Pairs fields if applicable.
  11. Under Visibility, select which Account Roles you want to have access to this button.
  12. Click Add when you have confirmed that the button accomplishes the task you want.

The button will show in the object type you added the button to.

2.5. Creating an Ansible Playbook Button

Red Hat CloudForms includes an option to create an Ansible Playbook custom button. This feature allows users to select a playbook to run as well as an inventory target to run it against. An Ansible playbook type button can be defined for any object type available.

Note

An Ansible Playbook catalog item must exist in order to create an Ansible Playbook custom button. For more information, see Creating an Ansible Playbook Service Catalog Item in the Provisioning Virtual Machines and Hosts guide.

  1. Navigate to AutomationAutomateCustomization.
  2. Click the Buttons accordion.
  3. From the Object Types tree, select the type of object you want to create the button for.
  4. Click Unassigned Buttons.
  5. Click image (Configuration), then image (Add a new Button).

    Note

    If image (Add a new Button) is not available, that means you have not created a button group for that object. To continue, create a button group first. See Section 2.3, “Creating a Custom Button Group”.

  6. Select Ansible Playbook from the Button Type drop-down menu.
  7. From the Playbook Catalog Item choose a playbook-backed catalog item to run.
  8. Choose a host from the Inventory against which to run the playbook. If Specific Hosts is selected, input the IP address or DNS names for each host in the text field, separating each with a comma.

    Note

    CloudForms supports two configurations for host value input:

    • To allow user-provided host values, set the custom button to Specific Hosts and leave the associated text field blank.
    • To use admin-specified host values, remove the Hosts field when creating the dialog the service uses. In this configuration, the field will not appear to users. See Service Dialogs for information on generating a service dialog.
  9. Type in a Text and Hover Text, and select the Icon you want to use.
  10. Select an Icon Color from the color selection palette that pops up.
  11. Check Open URL to open a browser window for the custom URL returned when the playbook is run.
  12. Select display options for the Ansible Playbook button from the Display for drop-down menu. Choose for the button to display in the list view, for single entities, or both.
  13. Choose how to submit objects to automate by selecting an option from the Submit drop-down menu. Selecting Submit all will pass all objects at once when the playbook is executed, while choosing One by one will run the the playbook each time per object.
  14. Click Add when you have confirmed that the button accomplishes the task you want.

2.6. Editing a Custom Button

This procedure shows you how to edit a custom button.

  1. Navigate to AutomationAutomateCustomization.
  2. From the Object Types dropdown, select the type of object you want to edit the button for.
  3. Click the button you want to edit.
  4. Click image (Configuration), image (Edit this Button).
  5. Modify as required.
  6. Click Save.

2.7. Deleting a Custom Button

This procedure shows you how to delete a custom button.

  1. Navigate to AutomationAutomateCustomization, then select the Buttons accordion.
  2. From the Object Type tree in the accordion menu, select the type of object you want to remove the button from.
  3. Click image (Configuration). then click image (Remove this button).
  4. Click OK to confirm that you want to delete this button.

2.8. Applying Visibility and Enablement Filtering Actions to Custom Buttons

Red Hat CloudForms adds methods for evaluating an expression to determine whether a custom button is visible and enabled. Each method has a target object, for example, a virtual machine or host, and expressions can set a custom button to visible, hidden, or disabled.

Note

Filtering works on single objects and is not applicable to lists.

To apply filtering actions to a custom button:

  1. Navigate to AutomationAutomateCustomization.
  2. Click the Buttons accordion. Select the custom button to use.
  3. Click image (Configuration), then image (Edit this Button).
  4. Click the Advanced tab.
  5. To set enablement filtering on a custom button:

    1. Under Enablement, click on Define Expression.
    2. Create a visibility expression using the expression editor tools.
    3. Click Confirm (Confirm) when finished defining the expression.
    4. Provide Disabled Button Text in the field.
  6. To set visibility filtering on a custom button:

    1. Under Visibility, click on Define Expression.
    2. Create a visibility expression using the expression editor tools.
    3. Click Confirm (Confirm) when finished defining the expression.
  7. Click Save.

2.9. Using a Custom Button

This procedure shows you how to use custom buttons to invoke a cluster, host, datastore, provider, virtual machine or instance.

  1. Go to the page for the item that you created a button for.
  2. Click the custom button group from the taskbar, and then your custom button.

The automate model is invoked for the specified item.

2.10. Initiating Automate from an Event

You can also use a Red Hat CloudForms Policy Event to initiate automation. You can either use the provided Raise Automation Event action or create a custom automation action. The first case will start in the /System/Process class, but then go to the Event that initiated the Automate model in the /System/Process/Event Class. If you create your own custom action, it will start from the /System/Process class and then go to the /System/Process/Request Class instead.

For example, suppose that you always want the same Automate model to occur when a virtual machine is created. You would use the Raise Automation Event Action. There are instances in the /System/Process/Event Class for the following Events that you can select as part of a Policy:

image

2.11. Creating a Policy for Automate

This procedure shows you how to create a policy for automate.

  1. Navigate to ControlExplorer.
  2. Click the Policies accordion, and select Control Policies.
  3. Select Vm Control Policies.
  4. Click image (Configuration), then image (Add a New Control Vm Policy).
  5. Type in a Description.
  6. Uncheck Active if you do not want this policy processed even when assigned to a resource.
  7. Click Add. You are brought to the page where you add conditions and events to your new policy.
  8. Click image (Configuration), then image (Edit this Policy’s Event assignments).

    • Check the events you want to use to send to an Automate Model.
    • Click Save.
    • From the Events area, click on the Description of the Event you want to assign an action to.
    • Click image (Edit Actions for this Policy Event).
  9. Select Raise Automation Event, and click image (Move selected Actions into this Event).
  10. Click Save.

You can now assign this policy to a Policy Profile. Then, assign the policy profile to the virtual machines. Every time this event happens on the virtual machine the appropriate Automate Model will be initiated.

Note

If you want the policy to initiate an Automate Model from the /System/Process/Request class, then you can create your own custom action. Be sure to have an instance in the /System/Process/Request class for it to map to.

2.12. Creating a Custom Automate Action

This procedure shows you how to create a custom Automate action.

  1. Navigate to ControlExplorer accordion.
  2. Click the Actions accordion.
  3. Click image (Configuration), then image (Add a new Action).
  4. Type in a Description for the Action.
  5. Select Invoke a Custom Automation from Action Type.
  6. In Custom Automation,

    • For Message, type create.
    • For Request, type in the name of the instance of the /System/Process/Request Class in the second.
  7. Type in the Attribute/Value Pairs fields if applicable.
  8. Click Add.

The action is created and can be added to a policy.