尽管已安装 Ansible 未能找到 boto3 和 botocore

pka*_*mol 5 python amazon-s3 ansible ansible-2.x

以下任务:

  - name: Fetch dump file from S3
      aws_s3:
        bucket: mybucket
        object: somedump.sql
        dest: /tmp/somedump.sql
        mode: get
      delegate_to: "{{ ec2_instance_ip }}"
Run Code Online (Sandbox Code Playgroud)

失败:

致命:[localhost -> 22.33.111.88]:失败!=> {"changed": false, "msg": "这个模块需要 boto3 和 botocore"}

$ ssh ubuntu@22.33.111.88
$ pip freeze
boto3==1.7.41
botocore==1.10.41

$ pip3 freeze
blinker==1.3
boto3==1.7.41
botocore==1.10.41
Run Code Online (Sandbox Code Playgroud)

目标机器是ubuntu/xenial这样我也负责安装python-minimal(鉴于机器只有开箱即用python3

因此,在目标机器上:

$(which python) --version
Python 2.7.12
Run Code Online (Sandbox Code Playgroud)

我已经在附加和不附加的情况下运行了上述游戏:

  vars:
    ansible_python_interpreter: /usr/bin/python3
Run Code Online (Sandbox Code Playgroud)

在任务结束时...

Rez*_*ney 4

您可以尝试降级“boto3”软件包看看是否没有问题?

获取可用版本:

pip install boto3==some_nonsense_word
Run Code Online (Sandbox Code Playgroud)

然后:

pip uninstall boto3
Run Code Online (Sandbox Code Playgroud)

最后:

pip install boto3==<VERSION>
Run Code Online (Sandbox Code Playgroud)

根据以下 GitHub 问题评论的调查结果进行回答:

https://github.com/ansible/ansible-modules-core/issues/2014#issuecomment-144620598