2016-02-10 10:51:39 +00:00
|
|
|
---
|
|
|
|
- hosts: localhost
|
2019-04-18 08:42:10 +00:00
|
|
|
become: False
|
2016-02-10 10:51:39 +00:00
|
|
|
gather_facts: False
|
|
|
|
|
|
|
|
tasks:
|
|
|
|
- name: Provision a set of instances
|
|
|
|
ec2:
|
|
|
|
key_name: "{{ aws.key_name }}"
|
|
|
|
aws_access_key: "{{ aws.access_key }}"
|
|
|
|
aws_secret_key: "{{ aws.secret_key }}"
|
|
|
|
region: "{{ aws.region }}"
|
|
|
|
group_id: "{{ aws.group}}"
|
|
|
|
instance_type: "{{ aws.instance_type}}"
|
|
|
|
image: "{{ aws.ami_id }}"
|
|
|
|
wait: true
|
|
|
|
count: "{{ aws.count }}"
|
|
|
|
instance_tags: "{{ aws.tags }}"
|
|
|
|
register: ec2
|
|
|
|
|
|
|
|
- name: Template the inventory
|
|
|
|
template:
|
2016-02-13 14:16:28 +00:00
|
|
|
src: ../templates/inventory-aws.j2
|
2016-02-10 10:51:39 +00:00
|
|
|
dest: "{{ inventory_path }}"
|
|
|
|
|
|
|
|
- name: Wait until SSH is available
|
2019-05-01 07:38:55 +00:00
|
|
|
wait_for:
|
2016-02-10 10:51:39 +00:00
|
|
|
host: "{{ item.public_ip }}"
|
|
|
|
port: 22
|
|
|
|
timeout: 300
|
|
|
|
state: started
|
2019-05-01 07:38:55 +00:00
|
|
|
delegate_to: localhost
|
2016-05-11 15:37:15 +00:00
|
|
|
with_items: "{{ec2.instances}}"
|