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

0 votes

Hi Guys,

I have created one key pair in AWS using Ansible-Playbook. But I don't need this key now. I want to remove this key. How can I do that from Ansible-Playbook?

Aug 12, 2020 in Ansible by akhtar
• 38,230 points
692 views

1 answer to this question.

0 votes

Hi@akhtar,

You can use the ec2_key module in your playbook. In this module, you have to set state value as absent. I have attached one playbook below for your reference.

- hosts: localhost
  tasks:
  - name: Remove key pair
    ec2_key:
      name: my_keypair
      region: ap-south-1
      state: absent
      aws_access_key: 
      aws_secret_key: 

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

Related Questions In Ansible

0 votes
1 answer

How to run a playbook from a specific task in Ansible?

Hi@akhtar, The --start-at-task option allows you to start ...READ MORE

answered Sep 15, 2020 in Ansible by MD
• 95,440 points
9,916 views
0 votes
1 answer

How do I wget a file from web server using shell in the ansible playbook

Hey Ayaan, you could probably use this ...READ MORE

answered Jan 24, 2019 in Ansible by Anushri
3,868 views
0 votes
1 answer

How to overwrite the content of a file in remote systems using Ansible playbook?

Hi@akhtar, You can find one argument in the ...READ MORE

answered Aug 2, 2020 in Ansible by MD
• 95,440 points
13,306 views
0 votes
1 answer

How to create a variable in Ansible Playbook?

Hi@akhtar, Variable in playbooks are very similar to using variables in ...READ MORE

answered Aug 2, 2020 in Ansible by MD
• 95,440 points
1,066 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,521 views
+2 votes
1 answer
0 votes
1 answer

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

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

answered Aug 12, 2020 in Ansible by MD
• 95,440 points
1,138 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,440 points
3,415 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