Answers: <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>
  
Answers: CC BY-SA 4.0
Answers: 2020-05-24T12:29:12.483Z
Answers: 2020-05-24T12:29:12.483Z
Answers: KK Patel
Answers: <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>
  
Answers: CC BY-SA 4.0
Answers: 2020-04-23T12:00:42.737Z
Answers: 2020-04-23T12:00:42.737Z
Answers: MLu
Body: <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>
  
Tags: <ansible><amazon-ec2><apache-httpd>
Title: Install apache on awa ec2 from locally installed ansible server on my laptop
UserDisplayName: Rajesh k
ThreadText: # 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.
  
  
  ---
  
  