我正在尝试使用IAM Role for EC2从AWS S3下载一些文件,但Ansible收到错误 . 其他Ansible win_ *模块效果很好 .
Windows Server有Python2和Python3,还有boto和boto3模块 . Cmd正在响应python命令 . 它在执行时打开Python3 . 我还在打开Python3时测试了'import boto'命令,以确保安装了模块 .
Ansible Playbook配置如下:
- name: test s3 module
hosts: windows
tasks:
- name: get s3 file
aws_s3:
bucket: drktests3
object: /test
dest: C:\tests3.txt
mode: get
当我运行此配置时,输出是这样的:
root@ip-172-31-22-4:/etc/ansible/playbooks# ansible-playbook s3test
PLAY [test s3 module] *******************************************************************************************************************************************
TASK [Gathering Facts] ******************************************************************************************************************************************
ok: [38.210.201.10]
TASK [get s3 file] **********************************************************************************************************************************************
[WARNING]: FATAL ERROR DURING FILE TRANSFER:
fatal: [38.210.201.10]: FAILED! => {"msg": "winrm send_input failed; \nstdout: Unable to initialize device PRN\r\nUnable to initialize device PRN\r\nUnable to initialize device PRN\r\n\nstderr ANSIBALLZ_WRAPPER : The term 'ANSIBALLZ_WRAPPER' is not recognized as the name \r\nof a cmdlet, function, script file, or operable program. Check the spelling of \r\nthe name, or if a path was included, verify that the path is correct and try \r\nagain.\r\nAt line:1 char:1\r\n+ ANSIBALLZ_WRAPPER = True # For test-module script to tell this is a \r\nANSIBALLZ_WR ...\r\n+ ~~~~~~~~~~~~~~~~~\r\n + CategoryInfo : ObjectNotFound: (ANSIBALLZ_WRAPPER:String) [], C \r\n ommandNotFoundException\r\n + FullyQualifiedErrorId :
如果我将主机值更改为localhost,则相同的脚本在主服务器(Linux Ubuntu)上运行 . 为什么Ansible无法在Windows服务器上执行python代码?
1 回答
我发现Ansible Docs中有一个关于这个问题的部分 .
因此,如果您想要执行此类过程,则必须解决此问题 .
我通过Ansible Documentation提供的建议解决了这个问题 .
使用这些示例代码时,首先使用delegate_to将文件下载到Master Ansible服务器 . 之后您将文件复制到Windows主机 .