How to do SSH in EC2 instance using Ansible Playbook

0 votes

Hi Guys,

I am trying to implement dynamic host in Ansible playbook. So that I can do SSH dynamically in EC2 instance. How can I do that?

Sep 21, 2020 in Ansible by akhtar
• 38,260 points
2,434 views

1 answer to this question.

0 votes

Hi@akhtar,

To configure your inventory dynamically you need to use python scripts. You can download the script from the below-given link.

https://raw.githubusercontent.com/ansible/ansible/stable-2.9/contrib/inventory/ec2.py

After that, you can do SSH in your EC2 instance and can configure something. You can take help from the below playbook.

- hosts: all
  remote_user: ec2-user
  become: yes
  tasks:
  - name: Install httpd
    package:
      name: httpd
      state: present
answered Sep 21, 2020 by MD
• 95,460 points

Related Questions In Ansible

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
4,151 views
0 votes
1 answer

How do I add ssh authorized keys in ansible playbook?

Hey @kailash use the authorized_key plugin that ...READ MORE

answered Feb 12, 2019 in Ansible by Kyra
1,525 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,818 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,264 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
4,024 views
+2 votes
1 answer
0 votes
1 answer

How to launch an EC2 instance using Ansible Playbook?

Hi@akhtar, Ansible has one module named ec2. This ...READ MORE

answered Aug 12, 2020 in Ansible by MD
• 95,460 points
2,041 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,460 points
14,380 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