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 20 in Ansible by akhtar
• 28,160 points
24 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 by MD
• 65,200 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
1,643 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 11, 2019 in Ansible by Kyra
413 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 in Ansible by MD
• 65,200 points
214 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 in Ansible by anonymous
• 160 points
78 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 26, 2018 in DevOps & Agile by DragonLord999
• 8,450 points
720 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 in Ansible by MD
• 65,200 points
99 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 in Ansible by MD
• 65,200 points
380 views