-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ansible role : ec2_creation on aws using ansible
- Loading branch information
Showing
4 changed files
with
44 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
--- | ||
- name: start an instance with a public IP address | ||
amazon.aws.ec2_instance: | ||
name: "{{ item.name }}" | ||
instance_type: "{{ type }}" # pick from /vars/main.yaml | ||
region: ap-south-1 | ||
security_group: default | ||
network: | ||
assign_public_ip: true | ||
image_id: "{{ item.image }}" | ||
aws_access_key: "{{ aws_access_key }}" # to access aws # from ansible vault | ||
aws_secret_key: "{{ aws_secret_key }}" | ||
tags: | ||
Environmient: Testing | ||
with_items: | ||
- { image: ami-01376101673c89611, name: amz-1 } | ||
- { image: ami-01376101673c89611, name: amz-2 } | ||
- { image: ami-0ad21ae1d0696ad58, name: ubuntu-1} | ||
- { image: ami-0ad21ae1d0696ad58, name: ubuntu-2} | ||
|
||
# Ansible won't create multiple instances with the same parameters unless specified differently. | ||
# Since the AMI ID is the same for two amz instances and two ubuntu instances, | ||
# if I execute the playbook without providing unique names, it may not create separate instances. | ||
# By providing unique names for each instance, I ensure the creation of 4 distinct instances, even if the AMI IDs are the same. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
--- | ||
type: t2.micro |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
--- | ||
- hosts: localhost | ||
become: yes | ||
gather_facts: true | ||
connection: local | ||
|
||
roles: | ||
- ec2_create |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
$ANSIBLE_VAULT;1.1;AES256 | ||
31643261363130373733303961373630623133393631316531353366346538346239653233363230 | ||
3837316665303631353438343736393438663633626634310a363735353238323739373761366632 | ||
66393533646235626164383936323233616263333664366334613361313739363530643932616465 | ||
6565326332333133350a623235323265313266643261353333323162343530633337373538626635 | ||
62333064626330656331356335636430376564653231646539633335383034303330353237633234 | ||
32663939353765653038623032393262393131313034386633643638643934343962313132663332 | ||
30303964313733346666393632363230336338383539333436653561613964363035646137326162 | ||
31376639323333393964373265323933383564373038653862373339356464643264323530373731 | ||
65323064336638646464646330323135336238653438333665333762393836666533 |