<p>You need to put <code>public ip address</code> or <code>hostname</code> assigned by aws ec2 service, if your aws ec2 instance is public.</p>

<p>If your aws ec2 instance is located in vpc, you won't be able to connect it directly. Either you need to setup routing through internet gateway or you have to setup ansible server in vpc. </p>

CC BY-SA 4.0
2020-05-24T12:29:12.483Z
2020-05-24T12:29:12.483Z
KK Patel
<p>If the instance has <em>Public IP</em> address and its <em>Security Group</em> permits access from your IP use that to tell Ansible where to connect. </p>

CC BY-SA 4.0
2020-04-23T12:00:42.737Z
2020-04-23T12:00:42.737Z
MLu
<p>I would like to install apache2 remotely on aws ec2 instance from my locally installed ansible server on my laptop. I have also the. pem key of the instance. Now what Ip need to put in /etc/ansible/hosts file inorder to connect ec2 instance from my laptop? </p>

<ansible><amazon-ec2><apache-httpd>
Install apache on awa ec2 from locally installed ansible server on my laptop
Rajesh k
# Install apache on awa ec2 from locally installed ansible server on my laptop

(Asked by: username_0 on 2020-04-23)

I would like to install apache2 remotely on aws ec2 instance from my locally installed ansible server on my laptop. I have also the. pem key of the instance. Now what Ip need to put in /etc/ansible/hosts file inorder to connect ec2 instance from my laptop?

**Tags:** ansible, amazon-ec2, apache-httpd


---

## 2 answers

### Answer by username_1 on 2020-05-24. Score: 1

You need to put `public ip address` or `hostname` assigned by aws ec2 service, if your aws ec2 instance is public.

If your aws ec2 instance is located in vpc, you won't be able to connect it directly. Either you need to setup routing through internet gateway or you have to setup ansible server in vpc.


---

### Answer by username_2 on 2020-04-23. Score: 0

If the instance has *Public IP* address and its *Security Group* permits access from your IP use that to tell Ansible where to connect.


---

