当我尝试使用ansible创建外部LB时,我总是会收到以下错误-
"validate_certs":true,"zones":null},"module_name":"ec2_elb_lb"},"msg":"此模块需要boto
此代码为-
- name: Ensure load balancer exists
ec2_elb_lb:
name: "{{ elb_name }}"
security_group_names: "{{ elb_security_group_name }}"
state: present
region: "{{ vpc_region }}"
subnets: "{{ elb_subnet_id }}"
purge_subnets: "{{ elb_purge_subnets }}"
cross_az_load_balancing: "{{ elb_cross_az_load_balancing }}"
connection_draining_timeout: "{{ elb_connection_draining_timeout }}"
listeners: "{{ elb_listeners }}"
stickiness: "{{ elb_stickiness }}"
health_check: "{{ elb_health_check }}"
aws_secret_key: "{{ SECRET }}"
scheme: external
register: elb
从消息中,您似乎需要使用以下命令安装boto:
pip install boto
或
sudo pip install boto
确保您在本地主机上运行这些任务,如下所示:
- hosts: localhost
connection: local
gather_facts: no
tasks:
- name: Ensure load balancer exists
ec2_elb_lb:
name: "{{ elb_name }}"
security_group_names: "{{ elb_security_group_name }}"
state: present
region: "{{ vpc_region }}"
subnets: "{{ elb_subnet_id }}"
purge_subnets: "{{ elb_purge_subnets }}"
cross_az_load_balancing: "{{ elb_cross_az_load_balancing }}"
connection_draining_timeout: "{{ elb_connection_draining_timeout }}"
listeners: "{{ elb_listeners }}"
stickiness: "{{ elb_stickiness }}"
health_check: "{{ elb_health_check }}"
aws_secret_key: "{{ SECRET }}"
scheme: external
register: elb
希望这对你有帮助。
您需要做的是指定您的PYTHONPATH。我遇到过这个问题,这个解决了我的问题。
export PYTHONPATH="/usr/lib/python2.6/site-packages"
对于我的pyenv构建,我必须使用:
export PYTHONPATH=/home/username/.pyenv/versions/ansible/lib/python2.7/site-packages
ec2_elb_lb需要boto而不是boto3,您可以使用pip install boto
安装它
如果要创建应用程序负载均衡器,请使用elb_application_lb
而不是ec2_elb_lb
。