You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am trying to configure Ansible to use AWS SSM to connect to my EC2 instances instead SSH.
I have a playbook with a duration of approximatly 12 min when using SSH. With AWS SSM setup, this one takes 24 minutes,
so it takes twice as long which is a problem for me.
The playbook consists of classic tasks: install packages, setup permissions, configure elasticsearch...
I have investigate the root cause of this, it seems that setup SSM connection takes approximatly 3 seconds for each task, whereas it's instantaneous with SSH.
Below an exemple, with an Ansible task, in which setup the connection takes 3 seconds:
I've never used it. But per design, using SSM connection feature will be always slower as using ssh. Because it's using S3 with multiple HTTP requests per TASK.
AFAIU, this is an expected behaviour.
I've never used it. But per design, using SSM connection feature will be always slower as using ssh. Because it's using S3 with multiple HTTP requests per TASK. AFAIU, this is an expected behaviour.
Sort of. The setup for both SSH and SSM connections can be painfully slow, however with SSH the tool itself has a mechanism ("ControlMaster") for setting up persistent connections which most people use as a way to boost SSH performance.
If you're a Red Hat Ansible customer, it's worth pushing for this module to get moved over to amazon.aws with official support added, in doing so it would be possible for the Cloud team to try and borrow some expertise from folks who've written the networking connection plugins which use Ansible's persistence support.
I think it might be interesting to see how Packer handles this and take inspiration from it. Instead of entirely relying on SSM, it open an SSH tunnel through SSM.
It has the advantage of not requiring an external S3 bucket for small data transfers, as it's still possible to do it via SSH, while still retaining the benefits of SSM : IAM authentication without using SSH keys, no inbound port required, no bastion host, ...
Summary
I am trying to configure Ansible to use AWS SSM to connect to my EC2 instances instead SSH.
I have a playbook with a duration of approximatly 12 min when using SSH. With AWS SSM setup, this one takes 24 minutes,
so it takes twice as long which is a problem for me.
The playbook consists of classic tasks: install packages, setup permissions, configure elasticsearch...
I have investigate the root cause of this, it seems that setup SSM connection takes approximatly 3 seconds for each task, whereas it's instantaneous with SSH.
Below an exemple, with an Ansible task, in which setup the connection takes 3 seconds:
![ssm](https://private-user-images.githubusercontent.com/10061868/403488666-03df2865-10d7-406f-bbb4-6440816cd18f.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzg5MzMwOTYsIm5iZiI6MTczODkzMjc5NiwicGF0aCI6Ii8xMDA2MTg2OC80MDM0ODg2NjYtMDNkZjI4NjUtMTBkNy00MDZmLWJiYjQtNjQ0MDgxNmNkMThmLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMDclMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjA3VDEyNTMxNlomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWNkNDgyMzMwZjM0OTlmZWM0ZjExNmUwNmQ2YjE5ZDRjYWEzZWQwOThlZjBiZjMxYmQwNDc3NDI5NzE3OTgxODcmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.njQHpAq0jlQGKJj4-Z_tgebAU4Qi4Xh6YQyH1i5jIcI)
I didn't find a lot of documentation on this issue (here: #1853 and here: https://forum.ansible.com/t/how-to-re-use-connection-across-tasks/38171) .
So I am creating this issue to track this (maybe it could also be a feature) and check if it's possible to improve speed or find othe solutions.
Issue Type
Bug Report
Component Name
community.aws.aws_ssm
Ansible Version
Collection Versions
AWS SDK versions
Configuration
OS / Environment
Debian 12, in a Docker container
Steps to Reproduce
Launch a playbook with AWS SSM connection configured.
Expected Results
Same duration of the playbook compared to using SSH connection.
Actual Results
Duration is twice as long in my case compared to using SSH connection.
Code of Conduct
The text was updated successfully, but these errors were encountered: