此模块需要Boto - ec2_elb_lb

时间:2016-05-16 12:19:47

标签: macos amazon-web-services amazon-ec2 ansible

当我尝试使用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

3 个答案:

答案 0 :(得分:1)

从消息中看,您需要使用以下命令安装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

希望这会对你有所帮助。

答案 1 :(得分:1)

您需要做的是指定您的PYTHONPATH。我遇到了这个问题而且这个问题已经解决了。

export PYTHONPATH="/usr/lib/python2.6/site-packages"

对于我的pyenv构建,我不得不使用:

export PYTHONPATH=/home/username/.pyenv/versions/ansible/lib/python2.7/site-packages

答案 2 :(得分:0)

ec2_elb_lb 需要 boto 而不是 boto3,您可以使用 pip install boto

安装它

如果您尝试创建应用程序负载均衡器,请使用 elb_application_lb 而不是 ec2_elb_lb