mirror of
https://bitbucket.org/atlassian/dc-deployments-automation.git
synced 2025-12-17 02:13:06 -06:00
DCD-1123: Add roles to support creating multiple basic EC2 instances into a VPC.
This commit is contained in:
38
roles/ec2-instance/tasks/main.yml
Normal file
38
roles/ec2-instance/tasks/main.yml
Normal file
@@ -0,0 +1,38 @@
|
||||
---
|
||||
|
||||
- name: Fetch AMI list for region
|
||||
ec2_ami_facts:
|
||||
region: "{{ aws_region }}"
|
||||
owner: "{{ ec2_ami_owner }}"
|
||||
filters:
|
||||
description: "{{ ec2_ami_description }}"
|
||||
register: amis
|
||||
|
||||
- name: Find the latest version of the AMI
|
||||
set_fact:
|
||||
latest_ami: "{{ amis.images | selectattr('name', 'defined') | sort(attribute='creation_date') | last }}"
|
||||
|
||||
- name: Provision EC2 host
|
||||
ec2:
|
||||
exact_count: 1
|
||||
count_tag:
|
||||
Name: "{{instance_name}}"
|
||||
keypair: "{{ ec2_keypair }}"
|
||||
region: "{{ aws_region }}"
|
||||
instance_type: "{{ ec2_type }}"
|
||||
image: "{{ latest_ami.image_id }}"
|
||||
group_id: "{{ sg.group_id }}"
|
||||
vpc_subnet_id: "{{ subnet.subnet.id }}"
|
||||
assign_public_ip: True
|
||||
volumes:
|
||||
- device_name: /dev/xvda
|
||||
volume_type: gp2
|
||||
volume_size: "{{ ec2_disk_size }}"
|
||||
wait: true
|
||||
instance_tags:
|
||||
Name: "{{ instance_name }}"
|
||||
name: "{{ instance_name }}"
|
||||
business_unit: "{{ business_unit }}"
|
||||
service_name: "{{ instance_name}}"
|
||||
resource_owner: "{{ resource_owner }}"
|
||||
register: ec2_instance
|
||||
Reference in New Issue
Block a user