# Local ping takes 2 minutes

**URL:** <https://forum.ansible.com/t/local-ping-takes-2-minutes/17614>\
**Category:** Ansible Project\
**Created:** [February 24, 2015, 9:40pm UTC](https://forum.ansible.com/t/local-ping-takes-2-minutes/17614 "2015-02-24T21:40:24Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Luis\_Marques](https://avatars.discourse-cdn.com/v4/letter/l/dfb087/32.png) [@Luis\_Marques](https://forum.ansible.com/u/Luis_Marques)\
**Post date:** [February 24, 2015, 9:40pm UTC](https://forum.ansible.com/t/local-ping-takes-2-minutes/17614/1 "2015-02-24T21:40:24Z")

</div>

Is it normal for this local ping to take two minutes?

`

$ cat hosts  
localhost ansible\_connection=local

$ cat test.yml

---

<div class="post-metadata">

**Author:** ![Stephen\_John\_Smoogen](https://avatars.discourse-cdn.com/v4/letter/s/ad7895/32.png) [@Stephen\_John\_Smoogen](https://forum.ansible.com/u/Stephen_John_Smoogen)\
**Post date:** [February 25, 2015, 12:01am UTC](https://forum.ansible.com/t/local-ping-takes-2-minutes/17614/2 "2015-02-25T00:01:26Z")

</div>

> Is it normal for this local ping to take two minutes?

Well you are doing a lot more than

ansible localhost -m ping

The tool is doing all the gathering facts which can take some time and the  
recap rules.

---

<div class="post-metadata">

**Author:** ![Luis\_Marques](https://avatars.discourse-cdn.com/v4/letter/l/dfb087/32.png) [@Luis\_Marques](https://forum.ansible.com/u/Luis_Marques)\
**Post date:** [February 25, 2015, 12:09am UTC](https://forum.ansible.com/t/local-ping-takes-2-minutes/17614/3 "2015-02-25T00:09:45Z")

</div>

OK. I created this scenario to isolate the issue. But consider my actual scenario: I want to use the digitalocean module to create a droplet or to ensure it already exists. Something that would normally take about a second (if it already exists) with an ansible playbook would take two minutes. Is that the best I can do with Ansible? Am I doing something wrong?

---

<div class="post-metadata">

**Author:** ![Stephen\_John\_Smoogen](https://avatars.discourse-cdn.com/v4/letter/s/ad7895/32.png) [@Stephen\_John\_Smoogen](https://forum.ansible.com/u/Stephen_John_Smoogen)\
**Post date:** [February 25, 2015, 12:19am UTC](https://forum.ansible.com/t/local-ping-takes-2-minutes/17614/4 "2015-02-25T00:19:00Z")

</div>

I think you are jumping to conclusions from way too little data 🙂

Here is what happens doing exactly what you did on a CentOS-7 box running  
on a Intel Core Duo from 2009.

[root@shizuku ~]# time ansible-playbook -i hosts test.yml

PLAY [localhost]

---

<div class="post-metadata">

**Author:** ![Stephen\_John\_Smoogen](https://avatars.discourse-cdn.com/v4/letter/s/ad7895/32.png) [@Stephen\_John\_Smoogen](https://forum.ansible.com/u/Stephen_John_Smoogen)\
**Post date:** [February 25, 2015, 12:20am UTC](https://forum.ansible.com/t/local-ping-takes-2-minutes/17614/5 "2015-02-25T00:20:12Z")

</div>

Also run with -vvv option and see if there is a line where it pauses for a  
while.

---

<div class="post-metadata">

**Author:** ![Brian\_Coca](https://avatars.discourse-cdn.com/v4/letter/b/6de8d8/32.png) [@Brian\_Coca](https://forum.ansible.com/u/Brian_Coca)\
**Post date:** [February 25, 2015, 12:28am UTC](https://forum.ansible.com/t/local-ping-takes-2-minutes/17614/6 "2015-02-25T00:28:59Z")

</div>

Just add gather\_facts: false to your play.

---

<div class="post-metadata">

**Author:** ![Stephen\_John\_Smoogen](https://avatars.discourse-cdn.com/v4/letter/s/ad7895/32.png) [@Stephen\_John\_Smoogen](https://forum.ansible.com/u/Stephen_John_Smoogen)\
**Post date:** [February 25, 2015, 1:00am UTC](https://forum.ansible.com/t/local-ping-takes-2-minutes/17614/7 "2015-02-25T01:00:51Z")

</div>

Duh. I forgot that advice. Using my earlier example on my slowboat box

[root@xanadu ansible]# time ansible-playbook -i hosts test.yml -vvv

PLAY [localhost]

---

<div class="post-metadata">

**Author:** ![Luis\_Marques](https://avatars.discourse-cdn.com/v4/letter/l/dfb087/32.png) [@Luis\_Marques](https://forum.ansible.com/u/Luis_Marques)\
**Post date:** [February 25, 2015, 1:05am UTC](https://forum.ansible.com/t/local-ping-takes-2-minutes/17614/8 "2015-02-25T01:05:45Z")

</div>

With “gather\_facts: false” it is instantaneous. I had already tried the verbose output, and it shows the following line where it gets stuck:

u’LANG=en\_US.UTF-8 LC\_CTYPE=en\_US.UTF-8 /usr/bin/python /Users/luismarques/.ansible/tmp/ansible-tmp-1424825965.19-173089065311241/setup; rm -rf /Users/luismarques/.ansible/tmp/ansible-tmp-1424825965.19-173089065311241/ \>/dev/null 2\>&1’]

I had tried to interrupt ansible (ctrl-C) and run that python command manually, and it had output some JSON after the two minutes (the facts?). It didn’t show any intermediate debug output.

I’m running ansible 1.8.3.

Is the gather\_facts flag the proper solution, or is it just a workaround?

Smooge: regarding your slow machines with fast execution, were you using “gather\_facts: false”?

---

<div class="post-metadata">

**Author:** ![Dick\_Davies](https://avatars.discourse-cdn.com/v4/letter/d/b9e5f3/32.png) [@Dick\_Davies](https://forum.ansible.com/u/Dick_Davies)\
**Post date:** [February 25, 2015, 9:55am UTC](https://forum.ansible.com/t/local-ping-takes-2-minutes/17614/9 "2015-02-25T09:55:16Z")

</div>

> With "gather\_facts: false" it is instantaneous. I had already tried the  
> verbose output, and it shows the following line where it gets stuck:
> 
> \<localhost\> u'LANG=en\_US.UTF-8 LC\_CTYPE=en\_US.UTF-8 /usr/bin/python  
> /Users/luismarques/.ansible/tmp/ansible-tmp-1424825965.19-173089065311241/setup;  
> rm -rf  
> /Users/luismarques/.ansible/tmp/ansible-tmp-1424825965.19-173089065311241/
> 
> > /dev/null 2\>&1']
> 
> I had tried to interrupt ansible (ctrl-C) and run that python command  
> manually, and it had output some JSON after the two minutes (the facts?). It  
> didn't show any intermediate debug output.

Ah, I'd guess it doesn't return anything until all facts are gathered  
(i.e. they don't 'stream').

If I had to bet\* I'd blame name resolution of some kind, but if you  
want to try science..

You have the generated python and it reproduces the error,  
so start by commenting everything out and uncomment+test until you've  
got the delay.

> I'm running ansible 1.8.3.
> 
> Is the gather\_facts flag the proper solution, or is it just a workaround?

If you don't actually use any of the facts, there's no downside.

\* ok you twisted my arm, $10 says DNS issues

---

<div class="post-metadata">

**Author:** ![Mark\_McCoy](https://avatars.discourse-cdn.com/v4/letter/m/ebca7d/32.png) [@Mark\_McCoy](https://forum.ansible.com/u/Mark_McCoy)\
**Post date:** [February 25, 2015, 3:53pm UTC](https://forum.ansible.com/t/local-ping-takes-2-minutes/17614/10 "2015-02-25T15:53:15Z")

</div>

DNS resolution timeout normally defaults to 2 minutes on most every OS that I’ve seen, so that is my thought as well.
