Restarting PATROL Agent on a server


You can perform multiple actions by using the Ansible Automation Platform (formerly called Ansible Tower). After the connector is configured, all actions supported by the application are available in BMC Helix Intelligent Automation.

This topic describes how to automatically restart a PATROL Agent on any of the servers in your environment by using the Ansible Automation Platform action available in BMC Helix Intelligent Automation. 

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 JSON format. 

Important

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

Before you begin

Ensure that the following tasks are completed before you create a policy:

  • In the Ansible Automation Platform application, the following tasks are completed:
    1. Install the PATROL Agent Restart script in Ansible Automation Platform. 

      Click here to view a sample YAML script for Linux and Windows

      Linux: 

      ******************* Begin of file ******************* 

      --- 

      - name: Ansible start PatrolAgent service 

        hosts: {{ targethost }} 

        gather_facts: true 

        tasks: 

          - name: Start the PatrolAgent  service with systemd 

            service: 

              name: PatrolAgent 

              state: restarted 

      ******************* End of file ******************* 

      Windows:  

      ******************* Begin of file ******************* 

      --- 

      - name: Ansible start PatrolAgent service 

        hosts: "{{ targethost }}" 

        gather_facts: true 

        tasks: 

          - name: Start the PatrolAgent service on Windows 

            ansible.builtin.service: 

              name: PatrolAgent 

              state: started 

      ******************* End of file ******************* 

      Note

      The variable targethost  will be passed into the script from BMC Helix Intelligent Automation and Ansible Automation Platform. 

    2. 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. 
    3. Create credentials that will be used by BMC Helix Intelligent Automation to connect to Ansible Automation Platform. 
    4. Create a project. 
    5. 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 Automation Platform documentation at docs.ansible.com.  

  • The Ansible Automation Platform connector is configured and is in a connected state.
    For more information, see Configuring-the-Ansible-Automation-Platform-on-premises-connector

To create a policy for restarting PATROL Agent by using Ansible Automation Platform

  1. Click Policies and then 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 select the event related to PATROL Agent disconnect, or on the Paste Event JSON tab, enter event in the JSON format, and click Done.

    Click here to view the sample event JSON
    1. Sample event JSON
      {
                 "msg": "Self-Monitoring: PATROL Agent on hostname.bmc.com:3181 is disconnected.",
                 "_tenant_id": "141****179",
                 "_entropy": "",
                 "creation_time": "1665376920176",
                 "severity_ordinal": "70",
                 "agent_name": "tanzu-kubectl",
                 "modelname": "",
                 "_signature": "-760793035",
                 "source_identifier": "8aae4e68-1f45-4ae4-aba1-4f0c847b097d",
                 "incident_id": "",
                 "_service_id": "[]",
                 "incident_company": "",
                 "_operations": "[]",
                 "details": "",
                 "_modified_time": "1665376980155",
                 "_notes": "[]",
                 "priority_ordinal": "50",
                 "_service_name": "[]",
                 "agent_address": "172.17.0.1",
                 "priority": "PRIORITY_1",
                 "server_id": "0",
                 "_node_service_mapping": "[]",
                 "object_id": "",
                 "_node_id": "[]",
                 "_identifier": "00538aea-5c05-4e8e-9c82-c3d721805025",
                 "tags": "[]",
                 "sub_category_ordinal": "10",
                 "instancename": "",
                 "_repeat_count": "0",
                 "user_assigned": "",
                 "componentalias": "",
                 "category_ordinal": "190",
                 "status": "CLOSED",
                 "object": "8aae4e68-1f45-4ae4-aba1-4f0c847b097d",
                 "metric_unit": "",
                 "_relationships": "{rstat=norelation}",
                 "sub_category": "OTHER",
                 "_tenant_name": "",
                 "_errors": "[]",
                 "metric_name": "",
                 "_ci_id": "20f988be-45af-4d88-926a-e772b7a7883b",
                 "source_port": "0",
                 "source_address": "",
                 "alias": "[BMC_ComputerSystem:hostname.bmc.com]",
                 "al_device_ipaddress": "172.17.0.1",
                 "class": "HELIX_SM_EV",
                 "_lifecycle_time": "59992",
                 "object_class": "HELIX_COMPONENT",
                 "severity": "CRITICAL",
                 "_arrival_time": "1665376920176",
                 "cdmclass": "",
                 "al_agent_os": "Linux",
                 "metric_value": "",
                 "_unmapped_data": "{}",
                 "al_agent_name": "hostname",
                 "significance": "0",
                 "sm_ev_type": "DISCONNECTED",
                 "al_agent_port": "3181",
                 "agent_port": "3181",
                 "status_ordinal": "30",
                 "_model": "HELIX_SM_EV",
                 "location": "",
                 "_node_service_key_mapping": "[]",
                 "category": "OPERATIONS_MANAGEMENT",
                 "source_hostname": "hostname.bmc.com"
             }

    image2022-10-31_10-14-48.pngThe Trigger Condition is generated based on the selected event. Remove the source hostname and continue with the next steps. 

  5. (Optional)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. 
      The tag key should start with an alphabet and end with an alphanumeric character. Key supports alphanumeric characters and periods, dashes, and underscores. 
  6. To add action to the policy, click Select Action and perform the following steps by using the action wizard:
    1. From the Pick an automation tool section, click the Ansible Automation Platform 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 Automation Platform instance appear. 
    3. (Optional) Use the Search Online option to dynamically search for actions in the Ansible Automation Platform application. 
    4. Click Select against the Launch a Job Template action.
      Search Ansible Tower Actions Online in a Policy_23401.png
      The wizard takes you to the next step to configure an action.
    5. Provide the following information:
      1. Enter the action name, description, and the HTTP Method. 
      2. In Request body, enter the extra variables that you might have used in Ansible Automation Platform:

        Sample request body for stopping an AWS EC2 instance
        {
             "extra_vars": {
             "targethost": "$.event.source_hostname"
             }
        } 

        image2022-10-31_10-13-46.png

      3. In Template Id, enter the name of the action. 

        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. 

    6. Click Done.
      The added action appears in the Action Configuration section on the Create Automation Policies page.
  7. In the Estimated Savings section, enter an approximate time (in minutes) and money (in USD) that you may save by automating this action.
  8. 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

 

Tip: For faster searching, add an asterisk to the end of your partial query. Example: cert*