Skip to content
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

SSM Bucket files AnsiballZ py files still not working, even on 5.1.0 #1622

Closed
1 task done
piotrkochan opened this issue Dec 18, 2022 · 2 comments
Closed
1 task done
Labels
bug This issue/PR relates to a bug needs_triage python3

Comments

@piotrkochan
Copy link

Summary

There was a aws_ssm patch (#1428) in the 5.1.0 release but unfortunately is looks like the problem is still present. I can log in to remote machine and see AnsiballZ_.py file with the following content:

<?xml version="1.0" encoding="UTF-8"?>
<Error><Code>TemporaryRedirect</Code><Message>Please re-send this request to the specified temporary endpoint. Continue to use the original request endpoint for future requests.</Message><Endpoint>testbucketkochan2.s3.eu-west-3.amazonaws.com</Endpoint><Bucket>testbucketkochan2</Bucket><RequestId>3FCG2TZ2ZCC0PJWF</RequestId><HostId>QdM+A9PlaMKaNEu9OrRHEP8eTkcCZgFP5pjz3WgkPeUEqNXu0mHAuEigjX54Bb/HicjB9XrzP569FLVIeq925A==</HostId></Error>sh-4.2$

I'm not using bucket encryption and my instances do have all the required permissions to the bucket.

Issue Type

Bug Report

Component Name

aws_ssm connection

Ansible Version

$ ansible --version
ansible [core 2.11.12] 
  config file = /home/ec2-user/ansible.cfg
  configured module search path = ['/home/ec2-user/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/local/lib/python3.7/site-packages/ansible
  ansible collection location = /home/ec2-user/.ansible/collections:/usr/share/ansible/collections
  executable location = /usr/local/bin/ansible
  python version = 3.7.15 (default, Oct 31 2022, 22:44:31) [GCC 7.3.1 20180712 (Red Hat 7.3.1-15)]
  jinja version = 3.1.2
  libyaml = True

Collection Versions

$ ansible-galaxy collection list
# /home/ec2-user/.ansible/collections/ansible_collections
Collection    Version
------------- -------
amazon.aws    5.1.0  
community.aws 5.1.0 

AWS SDK versions

$ pip3 show boto boto3 botocore
Name: boto
Version: 2.49.0
Summary: Amazon Web Services Library
Home-page: https://github.com/boto/boto/
Author: Mitch Garnaat
Author-email: [email protected]
License: MIT
Location: /home/ec2-user/.local/lib/python3.7/site-packages
Requires: 
Required-by: 
---
Name: boto3
Version: 1.26.32
Summary: The AWS SDK for Python
Home-page: https://github.com/boto/boto3
Author: Amazon Web Services
Author-email: None
License: Apache License 2.0
Location: /home/ec2-user/.local/lib/python3.7/site-packages
Requires: botocore, jmespath, s3transfer
Required-by: 
---
Name: botocore
Version: 1.29.32
Summary: Low-level, data-driven core of boto 3.
Home-page: https://github.com/boto/botocore
Author: Amazon Web Services
Author-email: None
License: Apache License 2.0
Location: /home/ec2-user/.local/lib/python3.7/site-packages
Requires: urllib3, jmespath, python-dateutil
Required-by: s3transfer, boto3

Configuration

$ ansible-config dump --only-changed
DEFAULT_HOST_LIST(/home/ec2-user/ansible.cfg) = ['/home/ec2-user/aws_ec2.yml']
DEFAULT_KEEP_REMOTE_FILES(env: ANSIBLE_KEEP_REMOTE_FILES) = True
INVENTORY_ENABLED(/home/ec2-user/ansible.cfg) = ['aws_ec2']

OS / Environment

amazon linux @ec2

Steps to Reproduce

My playbook is just a basic one to make some tests

---
- hosts: all
  vars:
    ansible_connection: aws_ssm
    ansible_aws_ssm_region: eu-west-3
    ansible_aws_ssm_bucket_name: testbucketkochan2
    ansible_python_interpreter: /usr/bin/python3
  gather_facts: true
  tasks:
    - debug: var=ansible_host
    - file:
        path: /home/ssm-agent/test
        state: directory

Expected Results

Directory was created on the remote

Actual Results

<i-05c88ea82e50451fe> (1, '  File "/home/ssm-user/.ansible/tmp/ansible-tmp-1671395140.5234485-7598-247480824655119/AnsiballZ_setup.py", line 1\r\r\n    <?xml version="1.0" encoding="UTF-8"?>\r\r\n    ^\r\r\nSyntaxError: invalid syntax\r\r', '')
<i-05c88ea82e50451fe> CLOSING SSM CONNECTION TO: i-05c88ea82e50451fe
fatal: [ip-10-0-11-87.eu-west-3.compute.internal]: FAILED! => {
    "ansible_facts": {},
    "changed": false,
    "failed_modules": {
        "ansible.legacy.setup": {
            "failed": true,
            "module_stderr": "",
            "module_stdout": "  File \"/home/ssm-user/.ansible/tmp/ansible-tmp-1671395140.4534886-7597-269557437818937/AnsiballZ_setup.py\", line 1\r\r\n    <?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\r\n    ^\r\r\nSyntaxError: invalid syntax\r\r",
            "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error",
            "rc": 1
        }
    },
    "msg": "The following modules failed to execute: ansible.legacy.setup\n"
}
<i-05c88ea82e50451fe> TERMINATE SSM SESSION: i-05c88ea82e50451fe-0ac29e575613e578f
fatal: [ip-10-0-1-46.eu-west-3.compute.internal]: FAILED! => {
    "ansible_facts": {},
    "changed": false,
    "failed_modules": {
        "ansible.legacy.setup": {
            "failed": true,
            "module_stderr": "",
            "module_stdout": "  File \"/home/ssm-user/.ansible/tmp/ansible-tmp-1671395140.5234485-7598-247480824655119/AnsiballZ_setup.py\", line 1\r\r\n    <?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\r\n    ^\r\r\nSyntaxError: invalid syntax\r\r",
            "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error",
            "rc": 1
        }
    },
    "msg": "The following modules failed to execute: ansible.legacy.setup\n"
}

PLAY RECAP ***********************************************************************************************************************************************************************************************************************************
ip-10-0-1-46.eu-west-3.compute.internal : ok=0    changed=0    unreachable=0    failed=1    skipped=0    rescued=0    ignored=0   
ip-10-0-11-87.eu-west-3.compute.internal : ok=0    changed=0    unreachable=0    failed=1    skipped=0    rescued=0    ignored=0 

Code of Conduct

  • I agree to follow the Ansible Code of Conduct
@ansibullbot
Copy link

Files identified in the description:

If these files are inaccurate, please update the component name section of the description or use the !component bot command.

click here for bot help

@ansibullbot ansibullbot added bug This issue/PR relates to a bug needs_triage python3 labels Dec 18, 2022
@tremble
Copy link
Contributor

tremble commented Jan 25, 2023

@piotrkochan,

Thanks for taking the time to open this issue. This issue primarily occurs when using a new bucket, or a region that was added after 2019 (#1616).

Version 5.2.0 has recently been released and should include a fix for this (#1677). As such I'm closing this issue. If you still encounter this issue with version 5.2.0 please feel free to re-open the issue, in which case please provide new output from ansible-playbook with the -vvvv option.

@tremble tremble closed this as completed Jan 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue/PR relates to a bug needs_triage python3
Projects
None yet
Development

No branches or pull requests

3 participants