Ansible在block/rescue中调用aws_s3 windows主机失败错误,难以理解
这个块在Linux中工作得很好! 我尝试使用aws_s3下载包,如果失败,则使用fall back从web下载 但我遇到了难以理解的错误,并指出了错误的原因: 我仅介绍实用代码,因为它是非常大的ansible项目的pard:Ansible在block/rescue中调用aws_s3 windows主机失败错误,难以理解,ansible,Ansible,这个块在Linux中工作得很好! 我尝试使用aws_s3下载包,如果失败,则使用fall back从web下载 但我遇到了难以理解的错误,并指出了错误的原因: 我仅介绍实用代码,因为它是非常大的ansible项目的pard: - name: Download package block: - name: Download package from S3 aws_s3: bucket: s3_pack object: "{{ package_
- 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 }}"
这就是错误:
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 5116 TO 10.0.6.6
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 5116 TO 10.0.6.6
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
TASK[包部署:从S3下载包]********************************************************************************************************************************************************************************************
任务路径:/main.yml:74
2020年4月17日星期五09:44:09+0000(0:00:01.608)0:04:08.479**********
在端口5116到10.0.6.6上为用户:管理员建立WINRM连接
正在检查winrm_主机10.0.6.69是否为IPv6地址
EXEC(通过管道包装器)
使用模块文件/home//lib64/python3.6/dist-packages/ansible/modules/cloud/amazon/aws_s3.py
EXEC(通过管道包装器)
EXEC(通过管道包装器)
致命:[10.0.6.69]:失败!=>更改=错误
模块_stderr:|-
调用带有“1”参数的“Create”时出现异常:第4行字符:21
+def_ansiballz_main():
+ ~
在“(”之后应该有一个表达式。
第12行字符:27
+除了(属性错误、操作错误):
+ ~
参数列表中缺少参数。
第14行字符:7
+如果scriptdir不是None:
+ ~
if语句中“if”之后缺少“(”。
第21行字符:7
+如果sys.version_info<(3,):
+ ~
if语句中“if”之后缺少“(”。
第21行字符:30
+如果sys.version_info<(3,):
+ ~
“,”之后缺少表达式。
第21行字符:25
+如果sys.version_info<(3,):
+ ~
“您的ansible\u python\u解释器
似乎被设置为PowerShell或类似的错误;为非常清楚起见,不支持使用Windows作为控制主机:
他们有说明说您可以不用使用WSL,但它不受支持:谢谢您的回答,mybe您知道如何使用用户/密码从s3下载,因为它不是公共的吗?也找到了这个答案