Skip to content

Instantly share code, notes, and snippets.

@hackcoderr
Last active December 27, 2020 11:18
Show Gist options
  • Save hackcoderr/5985a9468534a3b2bfef389005860e22 to your computer and use it in GitHub Desktop.
Save hackcoderr/5985a9468534a3b2bfef389005860e22 to your computer and use it in GitHub Desktop.
Launching the ec2 instance through Ansible playbook
- hosts: "localhost"
vars_files:
- secrets.yml
tasks:
- name: "Provisioning OS on AWS using Ansible"
ec2:
key_name: "key"
instance_type: "t2.micro"
image: "ami-0a9d27a9f4f5c0efc"
wait: yes
count: 3
instance_tags:
Name: AWS_Ansible_Instance
vpc_subnet_id: "subnet-d77560bf"
assign_public_ip: yes
region: "ap-south-1"
state: present
group_id: "sg-0108a92e39352ebf8"
aws_access_key: "{{access_key}}"
aws_secret_key: "{{secret_key}}"
register: X
- debug:
var: X.instances[0].private_ip
- debug:
var: X.instances[1].private_ip
- debug:
var: X.instances[2].private_ip
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment