# Ansible ping not giving an output

**URL:** <https://forum.ansible.com/t/ansible-ping-not-giving-an-output/33793>\
**Category:** Ansible Project\
**Tags:** aws\
**Created:** [September 11, 2020, 3:57pm UTC](https://forum.ansible.com/t/ansible-ping-not-giving-an-output/33793 "2020-09-11T15:57:11Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Eoghan\_O\_Hara](https://avatars.discourse-cdn.com/v4/letter/e/9f8e36/32.png) [@Eoghan\_O\_Hara](https://forum.ansible.com/u/Eoghan_O_Hara)\
**Post date:** [September 11, 2020, 3:57pm UTC](https://forum.ansible.com/t/ansible-ping-not-giving-an-output/33793/1 "2020-09-11T15:57:11Z")

</div>

Hi,

I am learning to use Ansible, and am at the stage of pinging a remote host, an AWS EC2 instance in this case.

However, when I run ansible ping I get no output, as below:

$ ssh ec2-user@ec2-DNS  
This system is not registered to Red Hat Insights. See [https://cloud.redhat.com/](https://cloud.redhat.com/)  
To register this system, run: insights-client --register

Last login: Fri Sep 11 15:10:27 2020 from **.**. **.**  
[ec2-user@ip-bla ~]$ logout  
Connection to ec2-DNS closed.

$ ls

ansible.cfg hosts

$ ansible -m ping all

$

Any ideas what I may be causing this? I have my ec2-DNS defined in my hosts file, and in ansible.cfg inventory is pointing at hosts in the current working directory. I also have remote\_user = ec2-user in ansible.cfg

Thanks in advance,  
Eoghan

---

<div class="post-metadata">

**Author:** ![Eoghan\_O\_Hara](https://avatars.discourse-cdn.com/v4/letter/e/9f8e36/32.png) [@Eoghan\_O\_Hara](https://forum.ansible.com/u/Eoghan_O_Hara)\
**Post date:** [September 11, 2020, 3:59pm UTC](https://forum.ansible.com/t/ansible-ping-not-giving-an-output/33793/2 "2020-09-11T15:59:38Z")

</div>

More information…

$ ansible --version  
ansible 2.8.4  
config file = /home/eohara/ansible/ansible.cfg  
configured module search path = [‘/home/eohara/.ansible/plugins/modules’, ‘/usr/share/ansible/plugins/modules’]  
ansible python module location = /usr/lib/python3.7/site-packages/ansible  
executable location = /usr/bin/ansible  
python version = 3.7.7 (default, Apr 10 2020, 07:59:19) [GCC 9.3.0]

I do not have Python installed on my EC2 instance yet, but if this was the issue I would expect an error message of some kind

---

<div class="post-metadata">

**Author:** ![Luca\_remix\_tj\_Lorenz](https://avatars.discourse-cdn.com/v4/letter/l/ea666f/32.png) [@Luca\_remix\_tj\_Lorenz](https://forum.ansible.com/u/Luca_remix_tj_Lorenz)\
**Post date:** [September 11, 2020, 4:01pm UTC](https://forum.ansible.com/t/ansible-ping-not-giving-an-output/33793/3 "2020-09-11T16:01:41Z")

</div>

Run ansible with more verbosity (-vvv) and then we should have enough informations.

---

<div class="post-metadata">

**Author:** ![Eoghan\_O\_Hara](https://avatars.discourse-cdn.com/v4/letter/e/9f8e36/32.png) [@Eoghan\_O\_Hara](https://forum.ansible.com/u/Eoghan_O_Hara)\
**Post date:** [September 11, 2020, 4:05pm UTC](https://forum.ansible.com/t/ansible-ping-not-giving-an-output/33793/4 "2020-09-11T16:05:44Z")

</div>

Hi Luca,

Thank you for the response!

$ ansible -vvv -m ping all  
ansible 2.8.4  
config file = /home/eohara/ansible/ansible.cfg  
configured module search path = [‘/home/eohara/.ansible/plugins/modules’, ‘/usr/share/ansible/plugins/modules’]  
ansible python module location = /usr/lib/python3.7/site-packages/ansible  
executable location = /usr/bin/ansible  
python version = 3.7.7 (default, Apr 10 2020, 07:59:19) [GCC 9.3.0]  
Using /home/eohara/ansible/ansible.cfg as config file  
host\_list declined parsing /home/eohara/ansible/hosts as it did not pass it’s verify\_file() method  
script declined parsing /home/eohara/ansible/hosts as it did not pass it’s verify\_file() method  
auto declined parsing /home/eohara/ansible/hosts as it did not pass it’s verify\_file() method  
Parsed /home/eohara/ansible/hosts inventory source with ini plugin

---

<div class="post-metadata">

**Author:** ![Luca\_remix\_tj\_Lorenz](https://avatars.discourse-cdn.com/v4/letter/l/ea666f/32.png) [@Luca\_remix\_tj\_Lorenz](https://forum.ansible.com/u/Luca_remix_tj_Lorenz)\
**Post date:** [September 11, 2020, 4:26pm UTC](https://forum.ansible.com/t/ansible-ping-not-giving-an-output/33793/5 "2020-09-11T16:26:12Z")

</div>

Looks like you’re having an issue with your inventory file, please check if file specified in -i parameter is a valid inventory file.

Luca

---

<div class="post-metadata">

**Author:** ![Eoghan\_O\_Hara](https://avatars.discourse-cdn.com/v4/letter/e/9f8e36/32.png) [@Eoghan\_O\_Hara](https://forum.ansible.com/u/Eoghan_O_Hara)\
**Post date:** [September 11, 2020, 4:59pm UTC](https://forum.ansible.com/t/ansible-ping-not-giving-an-output/33793/6 "2020-09-11T16:59:56Z")

</div>

The file specified in -i is hosts in the current working directory

See below

$ head -15 ansible.cfg

# config file for ansible – [https://ansible.com/](https://ansible.com/)

# ===============================================

# nearly all parameters can be overridden in ansible-playbook

# or with command line flags. ansible will read ANSIBLE\_CONFIG,

# ansible.cfg in the current working directory, .ansible.cfg in

# the home directory or /etc/ansible/ansible.cfg, whichever it

# finds first

[defaults]

# some basic default values…

inventory = hosts  
#library = /usr/share/my\_modules/

$ cat hosts

[example]  
public.IP.of.EC2instance

$

I can not see anything wrong with this

---

<div class="post-metadata">

**Author:** ![Eoghan\_O\_Hara](https://avatars.discourse-cdn.com/v4/letter/e/9f8e36/32.png) [@Eoghan\_O\_Hara](https://forum.ansible.com/u/Eoghan_O_Hara)\
**Post date:** [September 14, 2020, 8:58am UTC](https://forum.ansible.com/t/ansible-ping-not-giving-an-output/33793/7 "2020-09-14T08:58:02Z")

</div>

Any other suggestions would be greatly appreciated

---

<div class="post-metadata">

**Author:** ![Tej-Singh-Rana](https://avatars.discourse-cdn.com/v4/letter/t/b5e925/32.png) [@Tej-Singh-Rana](https://forum.ansible.com/u/Tej-Singh-Rana)\
**Post date:** [September 14, 2020, 9:01am UTC](https://forum.ansible.com/t/ansible-ping-not-giving-an-output/33793/8 "2020-09-14T09:01:35Z")

</div>

You need to add the ICMP option in the security groups.

---

<div class="post-metadata">

**Author:** ![Eoghan\_O\_Hara](https://avatars.discourse-cdn.com/v4/letter/e/9f8e36/32.png) [@Eoghan\_O\_Hara](https://forum.ansible.com/u/Eoghan_O_Hara)\
**Post date:** [September 14, 2020, 9:49am UTC](https://forum.ansible.com/t/ansible-ping-not-giving-an-output/33793/9 "2020-09-14T09:49:02Z")

</div>

Hi Tej,

I have tried that on my inbound rules, to no avail.

As a test, I set inbound and outbound rules in my security group to accept all traffic on all protocols. Still, I am seeing the same output

---

<div class="post-metadata">

**Author:** ![Tej-Singh-Rana](https://avatars.discourse-cdn.com/v4/letter/t/b5e925/32.png) [@Tej-Singh-Rana](https://forum.ansible.com/u/Tej-Singh-Rana)\
**Post date:** [September 14, 2020, 10:11am UTC](https://forum.ansible.com/t/ansible-ping-not-giving-an-output/33793/10 "2020-09-14T10:11:15Z")

</div>

Are you able to ping other ec2 instances without ansible?  
What is the output of the below command:----  
**ansible localhost -m ping**

---

<div class="post-metadata">

**Author:** ![Tej-Singh-Rana](https://avatars.discourse-cdn.com/v4/letter/t/b5e925/32.png) [@Tej-Singh-Rana](https://forum.ansible.com/u/Tej-Singh-Rana)\
**Post date:** [September 14, 2020, 10:14am UTC](https://forum.ansible.com/t/ansible-ping-not-giving-an-output/33793/11 "2020-09-14T10:14:34Z")

</div>

Try to define under the absolute path  
inventory = /home/eohara/ansible/hosts

---

<div class="post-metadata">

**Author:** ![Raju\_Das](https://avatars.discourse-cdn.com/v4/letter/r/7feea3/32.png) [@Raju\_Das](https://forum.ansible.com/u/Raju_Das)\
**Post date:** [September 14, 2020, 10:14am UTC](https://forum.ansible.com/t/ansible-ping-not-giving-an-output/33793/12 "2020-09-14T10:14:52Z")

</div>

**Hi Eoghan,**

**Are you able to run it explicitly using ( -i hosts)? And are u able to check --list-host? permission of the hosts file? password less auth has been configured?**

**WIth Regards**  
**Raju Das**

---

<div class="post-metadata">

**Author:** ![Tej-Singh-Rana](https://avatars.discourse-cdn.com/v4/letter/t/b5e925/32.png) [@Tej-Singh-Rana](https://forum.ansible.com/u/Tej-Singh-Rana)\
**Post date:** [September 14, 2020, 10:21am UTC](https://forum.ansible.com/t/ansible-ping-not-giving-an-output/33793/13 "2020-09-14T10:21:11Z")

</div>

Try with  
**ansible all -m ping -i hosts**  
It will work.

---

<div class="post-metadata">

**Author:** ![Eoghan\_O\_Hara](https://avatars.discourse-cdn.com/v4/letter/e/9f8e36/32.png) [@Eoghan\_O\_Hara](https://forum.ansible.com/u/Eoghan_O_Hara)\
**Post date:** [September 14, 2020, 10:24am UTC](https://forum.ansible.com/t/ansible-ping-not-giving-an-output/33793/14 "2020-09-14T10:24:26Z")

</div>

I can ping the current ec2 instance and another one without ansible.

The output of that command is below

eohara@LPTP630 ~/ansible  
$ ansible -vvv localhost -m ping  
ansible 2.8.4  
config file = /home/eohara/ansible/ansible.cfg  
configured module search path = [‘/home/eohara/.ansible/plugins/modules’, ‘/usr/share/ansible/plugins/modules’]  
ansible python module location = /usr/lib/python3.7/site-packages/ansible  
executable location = /usr/bin/ansible  
python version = 3.7.7 (default, Apr 10 2020, 07:59:19) [GCC 9.3.0]  
Using /home/eohara/ansible/ansible.cfg as config file  
host\_list declined parsing /home/eohara/ansible/hosts as it did not pass it’s verify\_file() method  
script declined parsing /home/eohara/ansible/hosts as it did not pass it’s verify\_file() method  
auto declined parsing /home/eohara/ansible/hosts as it did not pass it’s verify\_file() method  
Parsed /home/eohara/ansible/hosts inventory source with ini plugin

eohara@LPTP630 ~/ansible  
$

---

<div class="post-metadata">

**Author:** ![Eoghan\_O\_Hara](https://avatars.discourse-cdn.com/v4/letter/e/9f8e36/32.png) [@Eoghan\_O\_Hara](https://forum.ansible.com/u/Eoghan_O_Hara)\
**Post date:** [September 14, 2020, 10:26am UTC](https://forum.ansible.com/t/ansible-ping-not-giving-an-output/33793/15 "2020-09-14T10:26:06Z")

</div>

Tried this, no change

---

<div class="post-metadata">

**Author:** ![Eoghan\_O\_Hara](https://avatars.discourse-cdn.com/v4/letter/e/9f8e36/32.png) [@Eoghan\_O\_Hara](https://forum.ansible.com/u/Eoghan_O_Hara)\
**Post date:** [September 14, 2020, 10:32am UTC](https://forum.ansible.com/t/ansible-ping-not-giving-an-output/33793/16 "2020-09-14T10:32:22Z")

</div>

Hi,

It does not work with -i hosts

eohara@LPTP630 ~/ansible  
$ ansible all --list-hosts  
hosts (1):  
[ec2-18-132-46-235.eu-west-2.compute.amazonaws.com](http://ec2-18-132-46-235.eu-west-2.compute.amazonaws.com)

eohara@LPTP630 ~/ansible  
$

eohara@LPTP630 ~/ansible  
$ ls -lart  
total 25  
-rw-r–r-- 1 eohara FD+Group(513) 50 Sep 14 10:46 hosts  
-rw-r–r-- 1 eohara FD+Group(513) 19983 Sep 14 11:25 ansible.cfg

By password-less auth, you mean I have an ssh key added and I can ssh to the instance without entering a password? Then yes that is configured

---

<div class="post-metadata">

**Author:** ![Eoghan\_O\_Hara](https://avatars.discourse-cdn.com/v4/letter/e/9f8e36/32.png) [@Eoghan\_O\_Hara](https://forum.ansible.com/u/Eoghan_O_Hara)\
**Post date:** [September 14, 2020, 10:33am UTC](https://forum.ansible.com/t/ansible-ping-not-giving-an-output/33793/17 "2020-09-14T10:33:35Z")

</div>

Unfortunately, **ansible all -m ping -i hosts** still gives the same result

---

<div class="post-metadata">

**Author:** ![Tej-Singh-Rana](https://avatars.discourse-cdn.com/v4/letter/t/b5e925/32.png) [@Tej-Singh-Rana](https://forum.ansible.com/u/Tej-Singh-Rana)\
**Post date:** [September 14, 2020, 10:51am UTC](https://forum.ansible.com/t/ansible-ping-not-giving-an-output/33793/18 "2020-09-14T10:51:37Z")

</div>

Any special purpose to define this [ec2-18-132-46-235.eu-west-2.compute.amazonaws.com](http://ec2-18-132-46-235.eu-west-2.compute.amazonaws.com/) instead of IP of the ec2 instance ?

---

<div class="post-metadata">

**Author:** ![Dick\_Visser](https://avatars.discourse-cdn.com/v4/letter/d/d9b06d/32.png) [@Dick\_Visser](https://forum.ansible.com/u/Dick_Visser)\
**Post date:** [September 14, 2020, 11:33am UTC](https://forum.ansible.com/t/ansible-ping-not-giving-an-output/33793/19 "2020-09-14T11:33:39Z")

</div>

As stated on [https://docs.ansible.com/ansible/latest/modules/ping\_module.html](https://docs.ansible.com/ansible/latest/modules/ping_module.html),  
it is NOT ICMP ping, this is just a trivial test module that requires  
Python on the remote-node.  
If ansible ping fails, this means that your SSH config/setup is wrong.  
This needs to be fixed before you can do anything.  
It is covered in the 'getting started' pages:  
[https://docs.ansible.com/ansible/latest/user\_guide/intro\_getting\_started.html#getting-started](https://docs.ansible.com/ansible/latest/user_guide/intro_getting_started.html#getting-started)

---

<div class="post-metadata">

**Author:** ![Eoghan\_O\_Hara](https://avatars.discourse-cdn.com/v4/letter/e/9f8e36/32.png) [@Eoghan\_O\_Hara](https://forum.ansible.com/u/Eoghan_O_Hara)\
**Post date:** [September 14, 2020, 11:35am UTC](https://forum.ansible.com/t/ansible-ping-not-giving-an-output/33793/20 "2020-09-14T11:35:58Z")

</div>

Hi Tej,

No special purpose. I changed to IP now, no change

[Next page](https://forum.ansible.com/t/ansible-ping-not-giving-an-output/33793.md?page=2)
