Ansible - 区域 us-east-2a 似乎不适用于 aws 模块 boto.ec2

Ansible - Region us-east-2a does not seem to be available for aws module boto.ec2

我正在尝试使用 Ansible 创建 EC2 实例,但它显示以下错误:

区域 us-east-2a 似乎不适用于 aws 模块 boto.ec2。如果该区域确实存在,您可能需要升级 boto 或使用 endpoints_path.

进行扩展

不得不说我正在使用 Ansible 版本 2.3.1.0Boto 2.480

尝试创建安全组后立即显示错误:

---
  - name: Provision an EC2 Instance
    hosts: localhost
    connection: local
    gather_facts: False
    tags: provisioning
    # Necessary Variables for creating/provisioning the EC2 Instance
    vars_files: 
      - variables.yml
      - aws_auth.yml
    # Task that will be used to Launch/Create an EC2 Instance
    tasks:
      -   name: Create security group
              ec2_group:
              name: "{{ project_name }}_security_group"
              description: "{{ project_name }} security group"
              region: "{{ aws_region }}"
          rules:
              - proto: tcp
                type: ssh
                from_port: 22
                to_port: 22
                cidr_ip: 0.0.0.0/0
              - proto: tcp
                type: http
                from_port: 80
                to_port: 80
                cidr_ip: 0.0.0.0/0
              - proto: tcp
                type: https
                from_port: 443
                to_port: 443
                cidr_ip: 0.0.0.0/0
          rules_egress:
              - proto: all
                type: all
                cidr_ip: 0.0.0.0/0
      register: basic_firewall

访问密钥和秘密密钥已正确导出。我可以 运行 /etc/ansible/ec2.py --list 并显示所有预期数据。

谢谢。

us-east-2a 不是 区域 ,而是 可用区 。该区域称为 us-east-2

http://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/Concepts.RegionsAndAvailabilityZones.html

我在使用 ansible (2.9.6) 和 rds 模块时发现了这个问题:

- name: register db_facts
  rds:
    command: facts
    aws_access_key: "AWS_ACCESS_KEY"
    aws_secret_key: "AWS_SECRET_KEY"
    aws_region: "AWS_REGION_KEY"
    instance_name: "NAME_OF_RDS_INSTANCE"
  register: db_facts

问题是我正在配置 Ubuntu 16.04 实例和 python-boto 包。可用的 boto 库很旧,所以它没有所需的区域,因为我可以使用 python:

确认
>>> import boto.ec2
>>> for i in boto.ec2.regions():
...   print(i)
...
RegionInfo:us-east-1
RegionInfo:cn-north-1
RegionInfo:ap-northeast-1
RegionInfo:eu-west-1
RegionInfo:ap-southeast-1
RegionInfo:ap-southeast-2
RegionInfo:us-west-2
RegionInfo:us-gov-west-1
RegionInfo:us-west-1
RegionInfo:eu-central-1
RegionInfo:sa-east-1

我安装了更新版本的库来解决这个问题:

pip install boto --upgrade

这是升级库的结果:

>>> import boto.ec2
>>> for i in boto.ec2.regions():
...   print(i)
...
RegionInfo:us-west-1
RegionInfo:us-east-1
RegionInfo:ap-northeast-1
RegionInfo:ap-southeast-2
RegionInfo:sa-east-1
RegionInfo:ap-northeast-2
RegionInfo:us-east-2
RegionInfo:ap-southeast-1
RegionInfo:ca-central-1
RegionInfo:cn-north-1
RegionInfo:us-west-2
RegionInfo:us-gov-west-1
RegionInfo:ap-south-1
RegionInfo:eu-central-1
RegionInfo:eu-west-1
RegionInfo:eu-west-2