An outage hits, the team scrambles, and your SSH keys are suddenly the most valuable thing in the room. Sound familiar? That fire drill is exactly what Ansible EC2 Systems Manager can prevent, when configured with the right access model.
Ansible automates infrastructure with playbooks and predictable runs. AWS Systems Manager (SSM) gives EC2 instances a managed channel for executing commands without exposing ports or keys. Combined, they let you control servers with the precision of infrastructure as code and the safety of identity-based access.
Here is the basic logic. Instead of connecting Ansible to an instance directly, you let SSM handle the transport. Each EC2 host runs the SSM Agent, which authenticates through IAM roles. Ansible triggers commands using the AWS API, and Systems Manager runs them inside AWS’s managed control plane. No open SSH, no stray credentials.
The biggest mental shift is identity flow. You do not authorize users to servers, you authorize automation accounts to APIs. Permissions live in IAM policies tied to the instance roles or automation user. When configured well, rotating secrets becomes irrelevant because there are none. All connections flow through AWS identity.
How do I connect Ansible and EC2 Systems Manager?
You register each EC2 host with the SSM Agent and ensure the proper IAM role is attached. Then, in Ansible’s inventory, replace traditional SSH configuration with the SSM connection plugin. That’s it. Ansible sends commands through SSM and retrieves results via the AWS API. It feels like magic, but it is just good design.