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

Invoke-WebRequest : The remote server returned an error: (400) Bad Request #969

Closed
1 task done
yuvals41 opened this issue Mar 7, 2022 · 3 comments
Closed
1 task done
Labels
bug This issue/PR relates to a bug needs_triage python3

Comments

@yuvals41
Copy link

yuvals41 commented Mar 7, 2022

Summary

Hi everyone,

I am trying to create a task to run on aws windows server from s3 on us-east-1 region and it works.(the ansible run on us east-1 instance)

But when i try to run the same task that is located on eu-west-1 i get this error:

fatal: [server-us-east]: FAILED! => {"msg": "failed to transfer file to /home/user/.ansible/tmp/ansible-local-2098403x7s_9b/tmpshlm51pb C:\\Windows\\TEMP\\ansible-tmp-1646658454.6658366-20989-241211742733176\\AnsiballZ_win_shell.ps1:\nInvoke-WebRequest : The remote server returned an error: (400) Bad Request.\nAt line:2 char:1\n+ Invoke-WebRequest 'https://name-ansible.s3.amazonaws.com/i-0032d021a4f ...\n+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n + CategoryInfo : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-WebRequest], WebException\n + FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeWebRequestCommand\n \n\n"

We have tried to set up s3 bucket on eu-west-1 and still didn't work (ansible_aws_ssm_bucket_name: ansible-bucket-eu-west-1)

Issue Type

Bug Report

Component Name

ec2_instance

Ansible Version

$ ansible --version
ansible [core 2.12.2]
  config file = /etc/ansible/ansible.cfg
  configured module search path = ['/home/user/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python3/dist-packages/ansible
  ansible collection location = /home/user/.ansible/collections:/usr/share/ansible/collections
  executable location = /usr/bin/ansible
  python version = 3.8.10 (default, Nov 26 2021, 20:14:08) [GCC 9.3.0]
  jinja version = 2.10.1
  libyaml = True

Collection Versions

$ ansible-galaxy collection list
# /usr/lib/python3/dist-packages/ansible_collections
Collection                    Version
----------------------------- -------
amazon.aws                    2.1.0  
ansible.netcommon             2.5.0  
ansible.posix                 1.3.0  
ansible.utils                 2.4.3  
ansible.windows               1.9.0  
arista.eos                    3.1.0  
awx.awx                       19.4.0 
azure.azcollection            1.11.0 
check_point.mgmt              2.2.2  
chocolatey.chocolatey         1.1.0  
cisco.aci                     2.1.0  
cisco.asa                     2.1.0  
cisco.intersight              1.0.18 
cisco.ios                     2.6.0  
cisco.iosxr                   2.6.0  
cisco.ise                     1.2.1  
cisco.meraki                  2.6.0  
cisco.mso                     1.3.0  
cisco.nso                     1.0.3  
cisco.nxos                    2.8.2  
cisco.ucs                     1.6.0  
cloud.common                  2.1.0  
cloudscale_ch.cloud           2.2.0  
community.aws                 2.2.0  
community.azure               1.1.0  
community.ciscosmb            1.0.4  
community.crypto              2.2.0  
community.digitalocean        1.15.0 
community.dns                 2.0.6  
community.docker              2.1.1  
community.fortios             1.0.0  
community.general             4.4.0  
community.google              1.0.0  
community.grafana             1.3.0  
community.hashi_vault         2.2.0  
community.hrobot              1.2.2  
community.kubernetes          2.0.1  
community.kubevirt            1.0.0  
community.libvirt             1.0.2  
community.mongodb             1.3.2  
community.mysql               2.3.3  
community.network             3.0.0  
community.okd                 2.1.0  
community.postgresql          1.6.1  
community.proxysql            1.3.1  
community.rabbitmq            1.1.0  
community.routeros            2.0.0  
community.skydive             1.0.0  
community.sops                1.2.0  
community.vmware              1.17.1 
community.windows             1.9.0  
community.zabbix              1.5.1  
containers.podman             1.9.1  
cyberark.conjur               1.1.0  
cyberark.pas                  1.0.13 
dellemc.enterprise_sonic      1.1.0  
dellemc.openmanage            4.4.0  
dellemc.os10                  1.1.1  
dellemc.os6                   1.0.7  
dellemc.os9                   1.0.4  
f5networks.f5_modules         1.14.0 
fortinet.fortimanager         2.1.4  
fortinet.fortios              2.1.3  
frr.frr                       1.0.3  
gluster.gluster               1.0.2  
google.cloud                  1.0.2  
hetzner.hcloud                1.6.0  
hpe.nimble                    1.1.4  
ibm.qradar                    1.0.3  
infinidat.infinibox           1.3.3  
infoblox.nios_modules         1.2.1  
inspur.sm                     1.3.0  
junipernetworks.junos         2.8.0  
kubernetes.core               2.2.3  
mellanox.onyx                 1.0.0  
netapp.aws                    21.7.0 
netapp.azure                  21.10.0
netapp.cloudmanager           21.13.0
netapp.elementsw              21.7.0 
netapp.ontap                  21.15.1
netapp.storagegrid            21.9.0 
netapp.um_info                21.8.0 
netapp_eseries.santricity     1.2.13 
netbox.netbox                 3.5.1  
ngine_io.cloudstack           2.2.2  
ngine_io.exoscale             1.0.0  
ngine_io.vultr                1.1.0  
openstack.cloud               1.6.0  
openvswitch.openvswitch       2.1.0  
ovirt.ovirt                   1.6.6  
purestorage.flasharray        1.12.1 
purestorage.flashblade        1.9.0  
sensu.sensu_go                1.13.0 
servicenow.servicenow         1.0.6  
splunk.es                     1.0.2  
t_systems_mms.icinga_director 1.27.0 
theforeman.foreman            2.2.0  
vyos.vyos                     2.6.0  
wti.remote                    1.0.3  

# /home/user.ansible/collections/ansible_collections
Collection    Version
------------- -------
amazon.aws    3.0.0  
community.aws 3.0.0   

AWS SDK versions

$ pip show boto boto3 botocore
Name: boto3
Version: 1.20.37
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/user/.local/lib/python3.8/site-packages
Requires: jmespath, botocore, s3transfer
Required-by: 
---
Name: botocore
Version: 1.23.37
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/user/.local/lib/python3.8/site-packages
Requires: jmespath, urllib3, python-dateutil
Required-by: s3transfer, boto3

Configuration

$ ansible-config dump --only-changed

OS / Environment

target host on windows

Steps to Reproduce

  - name: git reset and pull 
    vars:
      ansible_connection: aws_ssm
      ansible_shell_type: powershell
      ansible_aws_ssm_region: "{{ AWS_REGION }}"
      ansible_aws_ssm_bucket_name: ansible-bucket
      ansible_aws_ssm_instance_id: "{{ hostvars[inventory_hostname].instance_id }}"
    win_shell: |
      git reset --hard FETCH_HEAD
      git pull -Xtheirs -a https://{{ gituser }}:{{ gitpassword }}@bitbucket.org/name/repo_name.git
    args:
      chdir: 'C:\shared_repos'
    environment:
      GIT_COMMITTER_NAME: 'jenkins@name.com'
      GIT_COMMITTER_EMAIL: 'jenkins'
    no_log: false
    register: cmdresult
    changed_when: "'Already up to date' not in cmdresult.stdout"

Expected Results

TASK [deploy : git reset and pull ] ***************************************************************************************************************************************
ok: [server-us-east]

Actual Results

fatal: [server-us-east]: FAILED! => {"msg": "The task includes an option with an undefined variable. The error was: 'dict object' has no attribute 'stderr'\n\nThe error appears to be in '/home/user/Documents/name/ansible/server/roles/deploy/tasks/main.yaml': line 149, column 7, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n  rescue:\n    - name: fail the playbook\n      ^ here\n"}

Code of Conduct

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

Files identified in the description:
None

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 Mar 7, 2022
@clcaldwell
Copy link

@yuvals41 Not seeing enough here to really see what is happening. Can you get the actual command that is failing (if you can't get it from the verbose Ansible logs, you could turn on Script tracing and then extract it from the Windows events ). Once you get the actual command - try running it directly from PowerShell and see if you can get a response with more error details. If you have Powershell 6/7+ available, try Invoke-WebRequest <the other args> -SkipHttpErrorCheck | fl -Property * , so we can see the full details of the web request and associated error.

If you can post all of that info here might be able to start trying to figure out the issue

@tremble
Copy link
Contributor

tremble commented Jul 10, 2022

@yuvals41

I suspect that this issue is a duplicate of #1190, which we recently fixed (should be in a release towards the end of the month) unfortunately there's not enough information in the issue to continue debugging.

The "actual results" section even appears to contain results that don't match the "steps to reproduce" section.

I'm going to close this issue, but if you're able to reproduce the issue and provide the additional information @clcaldwell asked for, feel free to reopen the issue.

@tremble tremble closed this as completed Jul 10, 2022
abikouo pushed a commit to abikouo/community.aws that referenced this issue Oct 24, 2023
…eys (ansible-collections#972)

 ec2_instance : Add hibernation_options and volumes->ebs->encrypted keys

Signed-off-by: GomathiselviS gomathiselvi@gmail.com
SUMMARY


May Fix ansible-collections#969
In order to support Stop-hibernate behavior for an ec2 instance the following keys are added to the ec2_instance module
"hibernation_option": true
"volumes": [
{
                "ebs": {
                    "encrypted": true
                }
            }

],
ISSUE TYPE


Bugfix Pull Request
Docs Pull Request
Feature Pull Request
New Module Pull Request

COMPONENT NAME

ADDITIONAL INFORMATION

Reviewed-by: Alina Buzachis <None>
Reviewed-by: GomathiselviS <None>
Reviewed-by: Mike Graves <mgraves@redhat.com>
Reviewed-by: Gonéri Le Bouder <goneri@lebouder.net>
Reviewed-by: Mark Chappell <None>
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

4 participants