Ansible invoking aws_s3 windows host in block/rescue failed error which hard to understand

35 views
Skip to first unread message

Meir Yanovich

unread,
Apr 17, 2020, 8:28:26 AM4/17/20
to Ansible Project
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)
        +                                 ~~~~~~~~~~~~~
        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])
       
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
           
+ 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
       
+  ~~~~~~~~~~~~~
           
+ 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)
        +                                 ~~~~~~~~~~~~~
        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])
       
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
           
+ 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
       
+  ~~~~~~~~~~~~~
           
+ 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



Jordan Borean

unread,
Apr 17, 2020, 2:51:56 PM4/17/20
to Ansible Project
You can’t run Python modules on Windows so this was never designed to work on those hosts.

Meir Yanovich

unread,
Apr 17, 2020, 3:22:18 PM4/17/20
to Ansible Project
didn't know that , 
How do i connect to s3 and download file using user/password ? 

Meir Yanovich

unread,
Apr 17, 2020, 3:30:15 PM4/17/20
to Ansible Project

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

Jordan Borean

unread,
Apr 17, 2020, 3:36:20 PM4/17/20
to Ansible Project

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.

Meir Yanovich

unread,
Apr 17, 2020, 3:48:10 PM4/17/20
to Ansible Project
ok i found this question that has been ask before 

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

On Friday, April 17, 2020 at 9:51:56 PM UTC+3, Jordan Borean wrote:

Jordan Borean

unread,
Apr 17, 2020, 4:13:10 PM4/17/20
to Ansible Project
Read through that issue you linked and you will see it.
Reply all
Reply to author
Forward
0 new messages