-
Notifications
You must be signed in to change notification settings - Fork 403
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Connection Issues with "aws_ssm.py" when S3 bucket is newly created #705
Comments
Files identified in the description:
If these files are inaccurate, please update the |
@jkritzen, can you provide bit more details like why you would need to define because once I remove TASK [ping] ************************************************************************************************************
fatal: [localhost]: FAILED! => {"msg": "failed to find the executable specified /usr/local/bin/session-manager-plugin. Please verify if the executable exists and re-try."} Ansible supported connections: |
@116davinder: It uses the S3 Bucket for transferring Files to the remote VM. Requirements:
As mentioned the connection module uses the Global URL from the S3 bucket (which needs 24h to propagate), when using the boto3 adressing style "path" the regional URL is generated. I can provide you the patched "aws_ssm.py" file. Kind regards, |
Hi @jkritzen, if possible, please provide bit more details about I have tried with various known options and I am unable to reproduce your error. ---
# Fetch all hosts in us-east-1, the hostname is the public DNS if it exists, otherwise the private IP address
plugin: 'aws_ec2'
regions:
- 'us-east-1'
filters:
# All instances with their `Project` tag set to match wildcard`
tag:Project:
- '*XXXX*'
# Add only instances managed by Terraform
tag:ManagedBy: '*Terraform*'
# Add only Preprod instances
tag:Environment: 'Preprod'
# Note: I(hostnames) sets the inventory_hostname. To modify ansible_host without modifying
# inventory_hostname use compose (see example below).
hostnames:
- 'private-ip-address'
- 'public-ip-address'
- 'dns-name'
# keyed_groups may be used to create custom groups
strict: false
keyed_groups:
# Add hosts to tag_Name_Value groups for each Name/Value tag pair
- prefix: 'tag'
key: 'tags'
# Create a group for each value of the AnsibleGroup tag
- key: 'tags.AnsibleGroup.split(",")'
separator: ''
# Set individual variables with compose
compose:
# Use the private IP address to connect to the host
# (note: this does not modify inventory_hostname, which is set via I(hostnames))
ansible_host: 'public_ip_address is defined | ternary(public_ip_address, private_ip_address)'
Error: TASK [ping] *****************************************************************************************************************************************************************
fatal: [10.72.13.189]: FAILED! => {"msg": "failed to find the executable specified /usr/local/bin/session-manager-plugin. Please verify if the executable exists and re-try."} |
Your local ansible controller doesn't fullfill the requirements:
You are missing the aws session manager plugin: The Inventory files contains the AWS instance id's instead of ip Adresses:
|
Thanks. |
Summary
When i create a S3 Bucket via terraform and then run ansible via AWS SSM i get error's from the ansible playbook cause SSM connection moduel uses the Global S3 Bucket DNS Name which DNS propagation will take up to 24h. The boto3 client doesn't follow the redirection, instead the redirection breaks the ansible playbook.
Issue Type
Bug Report
Component Name
aws_ssm.py (AWS Session manager Connection module)
Ansible Version
Collection Versions
AWS SDK versions
Configuration
$ ansible-config dump --only-changed
OS / Environment
Centos 7+8, Fedora 33, Amazon Linux 2 (Issue is Independent from OS)
Steps to Reproduce
Which results in:
Expected Results
The "aws_ssm.py" connection module uses a not recommended config wich causes a "HTTP 307 Temporary Redirect response" from the S3 URL:
More infos:
https://docs.aws.amazon.com/AmazonS3/latest/userguide/UsingRouting.html#TemporaryRedirection
https://aws.amazon.com/de/premiumsupport/knowledge-center/s3-http-307-response/
To avoid the 307 Temporary Redirect response, send requests only to the Regional endpoint in the same Region as your S3 bucket: https://boto3.amazonaws.com/v1/documentation/api/1.9.42/guide/s3.html
In general, the SDK will handle the decision of what style to use for you, but there are some cases where you may want to set it yourself. For instance, if you have a CORS configured bucket that is only a few hours old, you may need to use path style addressing for generating pre-signed POSTs and URLs until the necessary DNS changes have time to propagate.
Within the ssm connection module (aws_ssm.py) it can be fixed using the "path" adressing style by changing:
to
Actual Results
With current aws_ssm.py:
With config style "path":
Code of Conduct
The text was updated successfully, but these errors were encountered: