AWX Tower Teams Notification

3 minute read

Published:

Guide: Sending Notifications to Teams Webhook from AWX Tower

In this guide, you will learn how to send notifications to Microsoft Teams using a Webhook from AWX Tower, step by step.

End result should be something like this:

imageteam

Step 1: Creating a Teams Webhook

  1. Go to your Microsoft Teams channel.
  2. Click on the three dots in the upper right corner and navigate to “More options.”
  3. Go to the “Connectors” section and click on “Add” for “Incoming Webhook.”
  4. Provide a webhook name, and optionally add a profile picture. Copy the Webhook URL and save it somewhere.

Step 2: AWX Job Template Settings

  1. Go to the AWX interface and select or create the relevant “Job Template.”
  2. Navigate to the “Notifications” tab from the left menu.
  3. Click the “Add Notification” button and select “Webhook.”
  4. In the opened window, fill in the following details:
    • Name: Name of the notification
    • Webhook URL: The Teams Webhook URL you copied earlier
    • HTTP Method: POST
    • HTTP Headers (Optional):

      {
      "content-type": "application/json"
      }
      
    • Start message body:
        
     {   
     "@type": "MessageCard",
     "@context": "http://schema.org/extensions",
     "summary": "Job launched: {{ job.name }}",
     "title": "Job launched: {{ job.name }}",
     "themeColor": "FFFFFF",
     "sections": [
         {
             "activityTitle": "Details:",
             "activityImage": "https://georgekosmidis.azureedge.net/azure-architecture-icons/general/10010-icon-service-Quickstart-Center-2048x2048.png",
             "facts": [
                 {
                     "name": "Start date",
                     "value": ("{{ job.started }}")
                 },
                 {
                     "name": "Inventory",
                     "value": "{{ job.summary_fields.inventory.name }}"
                 },
                 {
                     "name": "Created by",
                     "value": "{{ job.summary_fields.created_by.first_name }} {{ job.summary_fields.created_by.last_name }}"
                 }
             ]
         }
     ],
     "potentialAction": [
         {
             "@context": "http://schema.org",
             "@type": "ViewAction",
             "name": "View on Ansible",
             "target": [
                 "{{ url }}"
             ]
         }
     ]
     }
        
    
    • Success message body:
        
     {
     "@type": "MessageCard",
     "@context": "http://schema.org/extensions",
     "summary": "Job success: {{ job.name }}",
     "title": "Job success: {{ job.name }}",
     "themeColor": "008000",
     "sections": [
         {
             "activityTitle": "Details:",
             "activityImage": "https://georgekosmidis.azureedge.net/azure-architecture-icons/general/10808-icon-service-Globe-Success-2048x2048.png",
             "facts": [
                 {
                     "name": "Start date",
                     "value": "{{ job.started }}"
                 },
                 {
                     "name": "End date",
                     "value": "{{ job.finished }}"
                 },
                 {
                     "name": "Inventory",
                     "value": "{{ job.summary_fields.inventory.name }}"
                 },
                 {
                     "name": "Created by",
                     "value": "{{ job.summary_fields.created_by.first_name }} {{ job.summary_fields.created_by.last_name }}"
                 }
             ]
         }
     ],
     "potentialAction": [
         {
             "@context": "http://schema.org",
             "@type": "ViewAction",
             "name": "View on Ansible",
             "target": [
                 "{{ url }}"
             ]
         }
     ]
     }
        
    
    • Error Message Body:
        
     {
     "@type": "MessageCard",
     "@context": "http://schema.org/extensions",
     "summary": "Job error: {{ job.name }}",
     "title": "Job error: {{ job.name }}",
     "themeColor": "FF0000",
     "sections": [
         {
             "activityTitle": "Details",
             "activityImage": "https://georgekosmidis.azureedge.net/azure-architecture-icons/general/10807-icon-service-Globe-Error-2048x2048.png",
             "facts": [
                 {
                     "name": "Start date:",
                     "value": "{{ job.started }}"
                 },
                 {
                     "name": "End date:",
                     "value": "{{ job.finished }}"
                 },
                 {
                     "name": "Inventory:",
                     "value": "{{ job.summary_fields.inventory.name }}"
                 },
                 {
                     "name": "Created by:",
                     "value": "{{ job.summary_fields.created_by.first_name }} {{ job.summary_fields.created_by.last_name }}"
                 }
             ]
         }
     ],
     "potentialAction": [
         {
             "@context": "http://schema.org",
             "@type": "ViewAction",
             "name": "View on AWX Tower",
             "target": [
                 "{{ url }}"
             ]
         }
     ]
     }
        
    
    • Approve Message Body:
        
     {
     "@type": "MessageCard",
     "@context": "https://schema.org/extensions",
     "summary": "Workflow approval node got Approved: {{ approval_node_name }}",
     "title": "Workflow approval node got Approved: {{ approval_node_name }}",
     "themeColor": "008000",
     "potentialAction": [
     {
     "@context": "http://schema.org",
     "@type": "ViewAction",
     "name": "View on Ansible",
     "target": [
     "{{ workflow_url }}"
     ]
     }
     ]
     }
        
    
  5. Click “Save” to save the notification settings.

Step 3: Running the Job and Receiving Notifications

  1. Run the Job Template.
  2. When the job starts or completes, AWX will automatically send a POST request to the Teams Webhook you specified.
  3. Go to your Microsoft Teams channel and see the notification sent by AWX.

By following this guide, you can send notifications to Microsoft Teams using a Webhook from AWX Tower. You can customize or enhance the steps according to your needs. Good luck!