Aqui está uma amostra de trabalho do ec2.ini (testado com ansible 2.1 & 2.3.1)
[ec2]
regions = us-east-1,us-west-2
regions_exclude =
destination_variable = private_ip_address
hostname_variable = peerio
vpc_destination_variable = private_ip_address
route53 = False
rds = False
elasticache = False
all_instances = False
#instance_states = pending, running, shutting-down, terminated, stopping, stopped
all_rds_instances = False
all_elasticache_replication_groups = False
all_elasticache_clusters = False
all_elasticache_nodes = False
cache_path = ~/.ansible/tmp
cache_max_age = 300
nested_groups = False
replace_dash_in_groups = True
expand_csv_tags = False
group_by_instance_id = True
group_by_region = True
group_by_availability_zone = True
group_by_ami_id = True
group_by_instance_type = True
group_by_key_pair = True
group_by_vpc_id = True
group_by_security_group = True
group_by_tag_keys = True
group_by_tag_none = True
group_by_route53_names = True
#pattern_include = staging-*
#pattern_exclude = staging-*
#instance_filters = instance-type=t1.micro,tag:env=staging
#only process items we tagged
instance_filters = tag:serviceclass=*
boto_profile = ansible
Em seguida, as instâncias devem ser listadas usando seu IP privado como identificador:
./ec2.py --list
{
"_meta": {
"hostvars": {
"10.255.100.138": {
"ansible_ssh_host": "10.255.100.138",
"ec2__in_monitoring_element": false,
"ec2_ami_launch_index": "0",
... "ec2_vpc_id": "vpc-57ed3733"
},
"10.255.100.142": {
"ansible_ssh_host": "10.255.100.142",
"ec2__in_monitoring_element": false,
...