我正在尝试使用Ansible创建EC2实例,但它显示以下错误:
区域us-east-2a似乎不适用于aws模块boto.ec2。如果区域肯定存在,则可能需要升级boto或使用endpoints_path进行扩展。
我必须说我正在使用 Ansible版本2.3.1.0 和 Boto 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并显示所有预期的数据。
谢谢。
答案 0 :(得分:2)
us-east-2a
不是区域,它是可用区。该地区名为us-east-2
。
http://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/Concepts.RegionsAndAvailabilityZones.html
答案 1 :(得分:0)
在使用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