How to create a key pair on AWS using Ansible-Playbook

0 votes

Hi Guys,

I am trying to launch an EC2 instance on AWS using Ansible, but I don't have any key created. Can anyone tell me how can I create one key on AWS using Ansible-Playbook?

Aug 12, 2020 in Ansible by akhtar
• 38,260 points
1,346 views

1 answer to this question.

0 votes

Hi@akhtar,

You can find the ec2_key module in Ansible. This is used to create a key pair on the AWS cloud. I have attached the below playbook for your reference.

- hosts: localhost
  tasks:
  - name: create a new ec2 key pair, returns generated private key
    ec2_key:
      name: my_keypair
      region: ap-south-1
      aws_access_key: 
      aws_secret_key: 

answered Aug 12, 2020 by MD
• 95,460 points

Related Questions In Ansible

0 votes
1 answer

How to create a simple S3 bucket on Ceph Rados Gateway using Ansible Playbook?

Hi@MD, Ansible has one module that can create ...READ MORE

answered Dec 4, 2020 in Ansible by akhtar
• 38,260 points
1,251 views
0 votes
1 answer

How to create a docker container using Ansible playbook?

Hi@akhtar, You can use the docker_container module in ...READ MORE

answered Aug 8, 2020 in Ansible by MD
• 95,460 points
4,233 views
0 votes
2 answers

How to create a directory in remote nodes using Ansible-Playbook?

You can read install and setup apache ...READ MORE

answered Aug 23, 2020 in Ansible by anonymous
• 160 points
4,118 views
0 votes
1 answer

How to create a user using Ansible Playbook?

Hi@akhtar, You can use the user module in ...READ MORE

answered Sep 1, 2020 in Ansible by MD
• 95,460 points
4,396 views
+15 votes
2 answers

Git management technique when there are multiple customers and need multiple customization?

Consider this - In 'extended' Git-Flow, (Git-Multi-Flow, ...READ MORE

answered Mar 27, 2018 in DevOps & Agile by DragonLord999
• 8,450 points
3,926 views
+2 votes
1 answer
0 votes
1 answer

How to delete a key pair in AWS from Ansible-Playbook?

Hi@akhtar, You can use the ec2_key module in ...READ MORE

answered Aug 12, 2020 in Ansible by MD
• 95,460 points
976 views
0 votes
1 answer

How to create a security group in AWS using Ansible-Playbook?

Hi@akhtar, You can use the ec2_group module in ...READ MORE

answered Aug 13, 2020 in Ansible by MD
• 95,460 points
3,744 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP