---
- name: Example of provisioning servers
hosts: 127.0.0.1
connection: local
tasks:
- name: "Deploying new instances"
local_action:
module: ec2
aws_access_key: THIS IS A SECRET
aws_secret_key: THIS IS A SECRET
assign_public_ip: yes
exact_count: {{ item.count }}
key_name: search-dev-sa-east-1a
group_id: sg-00b87865
region: {{ item.region }}
zone: {{ item.tag }}
instance_type: {{ item.type }}
image: ami-69d26774
wait: true
vpc_subnet_id: {{ item.subnet }}
user_data: "{{ lookup('file', 'userdata_api.txt') }}"
count_tag:
search: {{ item.tag }}
instance_tags:
Name: search-api-{{ item.tag }}-{{ 200 |random(step=5) }}
team: search
env: dev
search: {{ item.tag }}
chaordic:role: search
chaordic:product: search
volumes:
- device_name: /dev/sdb
device_type: io1
iops: 500
volume_size: 50
delete_on_termination: true
with_items:
- { region: 'sa-east-1', count: '2', tag: 'search-sa-east-1a', zone: 'a' , type: 't2.micro', subnet: 'subnet-9706efe0' }
- { region: 'sa-east-1', count: '2', tag: 'search-sa-east-1b', zone: 'b' , type: 't2.micro', subnet: 'subnet-66f22703' }
Thanks in advance.