【发布时间】:2021-12-23 06:43:01
【问题描述】:
当我运行这个简单的 Ansible 剧本时:
- name: EC2 Test Example
hosts: localhost
connection: local
gather_facts: False
tasks:
- name: EC2 Instance
ec2:
# Amazon EC2 key pair name
key_name: my-key-pair
# Amazon EC2 Security Group
group: my-security-group
instance_type: t2.micro
# Latest from https://wiki.debian.org/Cloud/AmazonEC2Image/Jessie
image: ami-221ea342
wait: yes
register: ec2
我使用venv/bin/ansible-playbook -i localhost, playbook.yml 运行:
PLAY [EC2 Test Example] ********************************************************
TASK [EC2 Instance] ************************************************************
fatal: [localhost]: FAILED! => {"changed": false, "failed": true, "msg": "boto required for this module"}
to retry, use: --limit @/Users/admin/temp/ansec2/playbook.retry
PLAY RECAP *********************************************************************
localhost : ok=0 changed=0 unreachable=0 failed=1
很明显,我已经在我正在使用的 venv 以及我的默认系统 Python 中安装了 boto:
➜ ansec2 venv/bin/pip list
Package Version
--------------- --------
ansible 2.2.1.0
boto 2.45.0
boto3 1.4.4
botocore 1.5.4
...
我已经阅读了一些类似的帖子,但没有看到可行的解决方案。
【问题讨论】:
-
你不再需要这个
-i localhost,hack了。你确定有必要吗?啊啊啊!!!这就是你的问题的根本原因。