# Ansible invoking aws\_s3 windows host in block/rescue failed error which hard to understand

**URL:** <https://forum.ansible.com/t/ansible-invoking-aws-s3-windows-host-in-block-rescue-failed-error-which-hard-to-understand/32712>\
**Category:** Ansible Project\
**Tags:** windows\
**Created:** [April 17, 2020, 12:28pm UTC](https://forum.ansible.com/t/ansible-invoking-aws-s3-windows-host-in-block-rescue-failed-error-which-hard-to-understand/32712 "2020-04-17T12:28:26Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Meir\_Yanovich](https://avatars.discourse-cdn.com/v4/letter/m/9de0a6/32.png) [@Meir\_Yanovich](https://forum.ansible.com/u/Meir_Yanovich)\
**Post date:** [April 17, 2020, 12:28pm UTC](https://forum.ansible.com/t/ansible-invoking-aws-s3-windows-host-in-block-rescue-failed-error-which-hard-to-understand/32712/1 "2020-04-17T12:28:26Z")

</div>

this block working fine in Linux !  
i trying to use aws\_s3 to download package and using fall back to download from web if its fail  
but im getting error which is hard to understand and pin point the couse of the error :  
i present only the prablematic code as it is pard of very big ansible project :

`

- name: Download package  
block:
- name: Download package from S3  
aws\_s3:  
bucket: s3\_pack  
object: “{{ package\_url | regex\_replace(‘^.\*\.[a-zA-Z]+/’, ‘’) }}”  
dest: “{{ ansible\_env.HOME }}/”  
mode: get  
rescue:
- name: Download package from FTP  
get\_url:  
url\_username: xxxxx  
url\_password: xxxxx  
dest: “{{ ansible\_env.HOME }}/”  
url: “{{ package\_url }}”  
`

and this is the error:

`  
TASK [package\_deploy : Download package from S3] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
task path: /main.yml:74  
Friday 17 April 2020 09:44:09 +0000 (0:00:01.608) 0:04:08.479 \*\*\*\*\*\*\*\*\*\*  
\<10.0.6.69\> ESTABLISH WINRM CONNECTION FOR USER: Administrator on PORT 5986 TO 10.0.6.69  
checking if winrm\_host 10.0.6.69 is an IPv6 address  
EXEC (via pipeline wrapper)  
Using module file /home//lib64/python3.6/dist-packages/ansible/modules/cloud/amazon/aws\_s3.py  
EXEC (via pipeline wrapper)  
EXEC (via pipeline wrapper)  
fatal: [10.0.6.69]: FAILED! =\> changed=false  
module\_stderr: |-  
Exception calling “Create” with “1” argument(s): "At line:4 char:21

- def \_ansiballz\_main():
- ~  
An expression was expected after ‘(’.  
At line:12 char:27
- except (AttributeError, OSError):
- ~  
Missing argument in parameter list.  
At line:14 char:7
- if scriptdir is not None:
- ~  
Missing ‘(’ after ‘if’ in if statement.  
At line:21 char:7
- if sys.version\_info \< (3,):
- ~  
Missing ‘(’ after ‘if’ in if statement.  
At line:21 char:30
- if sys.version\_info \< (3,):
- ~  
Missing expression after ‘,’.  
At line:21 char:25
- if sys.version\_info \< (3,):
- ~  
The ‘\<’ operator is reserved for future use.  
At line:23 char:32
- MOD\_DESC = (‘.py’, ‘U’, imp.PY\_SOURCE)
- ~  
Missing expression after ‘,’.  
At line:23 char:33
- MOD\_DESC = (‘.py’, ‘U’, imp.PY\_SOURCE)
- 

```auto

```

Unexpected token ‘imp.PY\_SOURCE’ in expression or statement.  
At line:23 char:32

- MOD\_DESC = (‘.py’, ‘U’, imp.PY\_SOURCE)
- ~  
Missing closing ‘)’ in expression.  
At line:23 char:46
- MOD\_DESC = (‘.py’, ‘U’, imp.PY\_SOURCE)
- ~  
Unexpected token ‘)’ in expression or statement.  
Not all parse errors were reported. Correct the reported errors and try again."  
At line:6 char:1
- $exec\_wrapper = [ScriptBlock]::Create($split\_parts[0])
- 

```auto

```

- CategoryInfo : NotSpecified: (🙂 , MethodInvocationException
- FullyQualifiedErrorId : ParseException

The expression after ‘&’ in a pipeline element produced an object that was not valid. It must result in a command  
name, a script block, or a CommandInfo object.  
At line:7 char:2

- &$exec\_wrapper
- 

```auto

```

- CategoryInfo : InvalidOperation: (🙂 , RuntimeException
- FullyQualifiedErrorId : BadExpression  
module\_stdout: ‘’  
msg: |-  
MODULE FAILURE  
See stdout/stderr for the exact error  
rc: 1

TASK [package\_deploy : Download package from FTP] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
task path: /main.yml:81  
Friday 17 April 2020 09:44:12 +0000 (0:00:02.549) 0:04:11.028 \*\*\*\*\*\*\*\*\*\*  
Using module file /home//lib64/python3.6/dist-packages/ansible/modules/net\_tools/basics/get\_url.py  
\<10.0.6.69\> ESTABLISH WINRM CONNECTION FOR USER: Administrator on PORT 5986 TO 10.0.6.69  
checking if winrm\_host 10.0.6.69 is an IPv6 address  
EXEC (via pipeline wrapper)  
fatal: [10.0.6.69]: FAILED! =\> changed=false  
module\_stderr: |-  
Exception calling “Create” with “1” argument(s): "At line:4 char:21

- def \_ansiballz\_main():
- ~  
An expression was expected after ‘(’.  
At line:12 char:27
- except (AttributeError, OSError):
- ~  
Missing argument in parameter list.  
At line:14 char:7
- if scriptdir is not None:
- ~  
Missing ‘(’ after ‘if’ in if statement.  
At line:21 char:7
- if sys.version\_info \< (3,):
- ~  
Missing ‘(’ after ‘if’ in if statement.  
At line:21 char:30
- if sys.version\_info \< (3,):
- ~  
Missing expression after ‘,’.  
At line:21 char:25
- if sys.version\_info \< (3,):
- ~  
The ‘\<’ operator is reserved for future use.  
At line:23 char:32
- MOD\_DESC = (‘.py’, ‘U’, imp.PY\_SOURCE)
- ~  
Missing expression after ‘,’.  
At line:23 char:33
- MOD\_DESC = (‘.py’, ‘U’, imp.PY\_SOURCE)
- 

```auto

```

Unexpected token ‘imp.PY\_SOURCE’ in expression or statement.  
At line:23 char:32

- MOD\_DESC = (‘.py’, ‘U’, imp.PY\_SOURCE)
- ~  
Missing closing ‘)’ in expression.  
At line:23 char:46
- MOD\_DESC = (‘.py’, ‘U’, imp.PY\_SOURCE)
- ~  
Unexpected token ‘)’ in expression or statement.  
Not all parse errors were reported. Correct the reported errors and try again."  
At line:6 char:1
- $exec\_wrapper = [ScriptBlock]::Create($split\_parts[0])
- 

```auto

```

- CategoryInfo : NotSpecified: (🙂 , MethodInvocationException
- FullyQualifiedErrorId : ParseException

The expression after ‘&’ in a pipeline element produced an object that was not valid. It must result in a command  
name, a script block, or a CommandInfo object.  
At line:7 char:2

- &$exec\_wrapper
- 

```auto

```

- CategoryInfo : InvalidOperation: (🙂 , RuntimeException
- FullyQualifiedErrorId : BadExpression  
module\_stdout: ‘’  
msg: |-  
MODULE FAILURE  
See stdout/stderr for the exact error  
rc: 1  
to retry, use: --limit @/home//ansible/site.retry

PLAY RECAP \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
10.0.6.69 : ok=16 changed=13 unreachable=0 failed=2  
localhost : ok=12 changed=4 unreachable=0 failed=0

`

---

<div class="post-metadata">

**Author:** ![jborean](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/jborean/32/1525_2.png) [@jborean](https://forum.ansible.com/u/jborean)\
**Post date:** [April 17, 2020, 6:51pm UTC](https://forum.ansible.com/t/ansible-invoking-aws-s3-windows-host-in-block-rescue-failed-error-which-hard-to-understand/32712/2 "2020-04-17T18:51:56Z")

</div>

You can’t run Python modules on Windows so this was never designed to work on those hosts.

---

<div class="post-metadata">

**Author:** ![Meir\_Yanovich](https://avatars.discourse-cdn.com/v4/letter/m/9de0a6/32.png) [@Meir\_Yanovich](https://forum.ansible.com/u/Meir_Yanovich)\
**Post date:** [April 17, 2020, 7:22pm UTC](https://forum.ansible.com/t/ansible-invoking-aws-s3-windows-host-in-block-rescue-failed-error-which-hard-to-understand/32712/3 "2020-04-17T19:22:18Z")

</div>

didn’t know that ,  
How do i connect to s3 and download file using user/password ?

---

<div class="post-metadata">

**Author:** ![Meir\_Yanovich](https://avatars.discourse-cdn.com/v4/letter/m/9de0a6/32.png) [@Meir\_Yanovich](https://forum.ansible.com/u/Meir_Yanovich)\
**Post date:** [April 17, 2020, 7:30pm UTC](https://forum.ansible.com/t/ansible-invoking-aws-s3-windows-host-in-block-rescue-failed-error-which-hard-to-understand/32712/4 "2020-04-17T19:30:15Z")

</div>

also why the fall back dosn’t work ? why does’t it download from the web  
i mean the rescue block.

---

<div class="post-metadata">

**Author:** ![jborean](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/jborean/32/1525_2.png) [@jborean](https://forum.ansible.com/u/jborean)\
**Post date:** [April 17, 2020, 7:36pm UTC](https://forum.ansible.com/t/ansible-invoking-aws-s3-windows-host-in-block-rescue-failed-error-which-hard-to-understand/32712/5 "2020-04-17T19:36:20Z")

</div>

Because get\_url is also a Python module [https://docs.ansible.com/ansible/latest/user\_guide/windows\_faq.html#can-i-run-python-modules-on-windows-hosts](https://docs.ansible.com/ansible/latest/user_guide/windows_faq.html#can-i-run-python-modules-on-windows-hosts).

The alternative for you is to either use win\_get\_url, or download the file on the controller using the Python modules and use win\_copy to copy it across.

---

<div class="post-metadata">

**Author:** ![Meir\_Yanovich](https://avatars.discourse-cdn.com/v4/letter/m/9de0a6/32.png) [@Meir\_Yanovich](https://forum.ansible.com/u/Meir_Yanovich)\
**Post date:** [April 17, 2020, 7:48pm UTC](https://forum.ansible.com/t/ansible-invoking-aws-s3-windows-host-in-block-rescue-failed-error-which-hard-to-understand/32712/6 "2020-04-17T19:48:10Z")

</div>

ok i found this question that has been ask before  
[https://github.com/ansible/ansible/issues/34135](https://github.com/ansible/ansible/issues/34135)

can you point me to some example using downloading the backet localy and then copy it to windows ?

---

<div class="post-metadata">

**Author:** ![jborean](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/jborean/32/1525_2.png) [@jborean](https://forum.ansible.com/u/jborean)\
**Post date:** [April 17, 2020, 8:13pm UTC](https://forum.ansible.com/t/ansible-invoking-aws-s3-windows-host-in-block-rescue-failed-error-which-hard-to-understand/32712/7 "2020-04-17T20:13:09Z")

</div>

Read through that issue you linked and you will see it.
