Hybrid and multi-cloud environments introduce operational complexity. However, integrating Red Hat Ansible Automation Platform with ServiceNow for public cloud bridges the gap between automation and IT service management (ITSM). This article explains how this integration enables teams to operate more swiftly, intelligently, and with fewer manual bottlenecks.
4 benefits of the Ansible & ServiceNow integration
Keeping IT operations smooth while managing multi-cloud environments (i.e., Amazon Web Services, AWS and Azure) is a growing challenge. Let's dive into how this powerful combination transforms cloud and IT operations, from automated incident remediation to self-service provisioning and real-time CMDB synchronization.
Figure 1 depicts this integration in a multi-cloud architecture environment.

1. Automated incident resolution
When cloud infrastructure fails—whether it's an AWS EC2 crash, CPU spike, an Azure virtual machine (VM) disk filling up, or a network misconfiguration—ServiceNow can automatically trigger Ansible playbooks to fix the issue before it impacts users.
For example, let's say ServiceNow receives an alert from AWS CloudWatch about a spiking CPU.
An Ansible playbook executes to:
- Scale up the instance (or deploy a new one).
- Restart the failing service.
- Log all actions back in ServiceNow for audit trails.
The cpu_remmediation.yaml playbook follows:
---
- name: Use ServiceNow CMDB as Dynamic Inventory
hosts: servicenow.cmdb_ci_cloud_instance
connection: local
gather_facts: false
tasks:
- name: List all AWS EC2 instances from ServiceNow
debug:
msg: "Instance {{ item.name }} (ID: {{ item.sys_id }}) is in {{ item.cloud }}"
loop: "{{ query('servicenow.snow_record', table='cmdb_ci_cloud_instance',
query='cloud=AWS') }}"
2. Effortless multi-cloud infrastructure deployment
Deploying and managing resources across AWS, Azure, and on-premise environments becomes seamless with the Ansible Automation Platform infrastructure-as-code (IaC) capabilities tracked within ServiceNow.
In this example, a compliance policy requires OS updates across 500 servers. The Ansible Automation Platform applies the patch and logs the change in ServiceNow for audit trails.
The dynamic_inventory_snow.yml playbook follows:
---
- name: Use ServiceNow CMDB as Dynamic Inventory
hosts: servicenow.cmdb_ci_cloud_instance
connection: local
gather_facts: false
tasks:
- name: List all AWS EC2 instances from ServiceNow
debug:
msg: "Instance {{ item.name }} (ID: {{ item.sys_id }}) is in {{ item.cloud }}"
loop: "{{ query('servicenow.snow_record', table='cmdb_ci_cloud_instance',
query='cloud=AWS') }}"
3. Self-service cloud provisioning
Self-service cloud provisioning allows teams to request cloud resources (i.e., AWS S3 buckets or Azure VMs) through the ServiceNow service catalog, while Ansible Automation Platform handles the deployment behind the scenes.
In this example, a developer requests an Azure Kubernetes (AKS) cluster via ServiceNow. Ansible Automation Platform automates the provisioning, ensuring proper tagging and security policies.
The following is the provisioning_az_rhel.yml playbook:
---
- name: Provision Azure RHEL VM from ServiceNow Request
hosts: localhost
vars:
snow_request_id: "{{ snow_request_id }}"
tasks:
- name: Get request details from ServiceNow
servicenow.itsm.request_item:
sys_id: "{{ snow_request_id }}"
register: request_details
- name: Deploy Azure RHEL VM
azure.azcollection.azure_rm_virtualmachine:
resource_group: "{{ request_details.resource_group }}"
name: "{{ request_details.vm_name }}"
vm_size: Standard_B2s
admin_username: azureuser
ssh_public_keys:
- path: /home/azureuser/.ssh/authorized_keys
key_data: ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABA...
image:
offer: RHEL
publisher: RedHat
sku: 8-lvm
version: latest
os_disk_size_gb: 64
- name: Register VM in ServiceNow CMDB
servicenow.itsm.cmdb_ci_cloud_instance:
name: "{{ request_details.vm_name }}"
ip_address: "{{ azure_vm.ip_address }}"
cloud: Azure
operational_status: In Production
sys_class_name: cmdb_ci_cloud_instance
- name: Update ServiceNow request as fulfilled
servicenow.itsm.request_item:
sys_id: "{{ snow_request_id }}"
state: Closed
close_notes: "RHEL VM {{ request_details.vm_name }} provisioned in Azure (IP: {{
azure_vm.ip_address }})."
4. Cloud cost optimization
Ansible Automation Platform can automatically decommission unused cloud resources (i.e., idle AWS EC2 instances) based on ServiceNow data, reducing waste and controlling costs.
In this example, ServiceNow flags an untagged, unused virtual machine (VM). Ansible Automation Platform shuts it down, terminates it, and updates the CMDB.
The cost_svgs_untag.yml playbook is as follows:
---
- name: Delete Unused AWS EC2 Instances
hosts: localhost
vars:
unused_threshold_days: 30
tasks:
- name: Get all EC2 instances not in ServiceNow CMDB
amazon.aws.ec2_instance_info:
filters:
tag:Owner: absent
register: aws_instances
- name: Terminate unused instances
amazon.aws.ec2_instance:
instance_id: "{{ item.instance_id }}"
state: terminated
loop: "{{ aws_instances.instances }}"
when: item.launch_time | datetime_diff('now', 'days') > unused_threshold_days
- name: Log deleted instances in ServiceNow
servicenow.itsm.change_request:
short_description: Cleaned up unused EC2 instances
description: "Terminated: {{ aws_instances.instances |
map(attribute='instance_id') | list }}"
Why this integration matters
Combining the power of Ansible Automation Platform with the capabilities of ServiceNow ITSM creates a seamless, event-driven cloud management experience. Whether you’re handling incidents, changes, or provisioning, this integration helps IT teams work smarter across multi-cloud environments, as well as:
- Faster response times: Event-driven automation means fewer manual tickets.
- Consistency: You can enforce policies uniformly across AWS, Azure, and hybrid environments.
- Audit-friendly features: You can track every automated action in ServiceNow.
Figure 2 shows a the overall workflow discussed in this article.

Explore more
Want to dive deeper? Start by exploring the Ansible Automation Platform and ServiceNow modules to experiment with simple playbooks and witness the impact firsthand.
Explore the Ansible Automation Platform and ServiceNow integration: