Restarting PATROL Agent on a server
While creating an action, you can use an event stored in the BMC Helix Intelligent Automation database or provide an event in JSON format.
Before you begin
Ensure that the following tasks are completed before you create a policy:
- In the Ansible Tower application, the following tasks are completed:
Install the PATROL Agent Restart script in Ansible Tower.
- Build an inventory with the PATROL Agents for Linux and/or Windows and add the target hosts where the PATROL Agents are running to the inventory based on your environment.
- Create credentials that will be used by BMC Helix Intelligent Automation to connect to Ansible Tower.
- Create a project.
Create a job template for restarting the PATROL Agent by using the following information:
Field
Description
Valid values/example
Name
Enter a name.
Start PATROL Agent Service
Description
Enter a description.
-
Job Type
Select Run.
-
Inventory
Enter the name of the inventory created for PATROL Agents.
Project
Enter the project name.
Intelligent Automation
Playbook
Select the playbook to be launched with this template.
This is the YAML script created in the earlier step.
Credentials
Select the credentials created in the earlier step.
Extra Variables
Select the Prompt on Launch check box to be able to choose command line variables even if a default value provided in the template.
For more information, see the Ansible Tower documentation at docs.ansible.com.
- The Ansible Tower connector is configured and is in a connected state.
For more information, see Configuring-the-Ansible-Tower-connector.
To create a policy for restarting PATROL Agent by using Ansible Tower
- Click Policies and then click Create Automation Policy.
- In the Policy Information section, enter a unique name and an optional description for the policy.
- Select Manual or Automatic depending upon whether you want to execute the policy manually or automatically based on the incoming events.
In the Trigger section, click Browse and select the event related to PATROL Agent disconnect, or on the Paste Event JSON tab, enter event in the JSON format, and click Done.
The Trigger Condition is generated based on the selected event. Remove the source hostname and continue with the next steps.
- (Optional)To add system or custom tags to the policy, perform the following steps:
- System tags: Select one or more tags from the list of available system tags.
Based on the event, some system tags are displayed. - 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.
- System tags: Select one or more tags from the list of available system tags.
- To add action to the policy, click Select Action and perform the following steps by using the action wizard:
- From the Pick an automation tool section, click the Ansible Tower connector name.
Only configured connectors are displayed here. The wizard takes you to the next step to select an action. - Click Sync Actions.
All job template and workflow template actions in your Ansible Tower instance appear. - Click Select against the Launch a Job Template action.
The wizard takes you to the next step to configure an action. - Provide the following information:
- Enter the action name, description, and the HTTP Method.
In Request body, enter the extra variables that you might have used in Ansible Tower:
Sample request body for stopping an AWS EC2 instance{
"extra_vars": {
"targethost": "$.event.source_hostname"
}
}In Template Id, enter the name of the action.
- Click Done.
The added action appears in the Action Configuration section on the Create Automation Policies page.
- From the Pick an automation tool section, click the Ansible Tower connector name.
- In the Estimated Savings section, enter an approximate time (in minutes) and money (in USD) that you may save by automating this action.
- Select Publish Policy and click Save to publish the policy.
Where to go from here
When an event appears in BMC Helix Intelligent Automation, the Launch Job Template action in the policy is triggered and the policy runs. To view the status or other details of the policy run, go to the History page. For more information, see Viewing-automation-policy-runs-history