# need to test Ping

**URL:** <https://forum.ansible.com/t/need-to-test-ping/38628>\
**Category:** Ansible Project\
**Created:** [December 15, 2023, 8:57am UTC](https://forum.ansible.com/t/need-to-test-ping/38628 "2023-12-15T08:57:20Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![thirumalairaja](https://avatars.discourse-cdn.com/v4/letter/t/c6cbf5/32.png) [@thirumalairaja](https://forum.ansible.com/u/thirumalairaja)\
**Post date:** [December 15, 2023, 8:57am UTC](https://forum.ansible.com/t/need-to-test-ping/38628/1 "2023-12-15T08:57:20Z")

</div>

hello team,

i need to perform ping command to check the ip address is that is possible in ansible i was tested with blow code i am getting error

- name: Ping the IP address  
ansible.builtin.command: “ping -c 4 10.144.35.9”  
register: ping\_result  
tags:
- ping

---

<div class="post-metadata">

**Author:** ![Stu](https://avatars.discourse-cdn.com/v4/letter/s/3ec8ea/32.png) [@Stu](https://forum.ansible.com/u/Stu)\
**Post date:** [December 15, 2023, 9:04am UTC](https://forum.ansible.com/t/need-to-test-ping/38628/2 "2023-12-15T09:04:00Z")

</div>

Your formatting is off and your missing a few bits

- name: Ping the IP address

ansible.builtin.command:

cmd: ping -c 4 10.144.35.9

register: ping\_result

tags:

- ping

should work

---

<div class="post-metadata">

**Author:** ![thirumalairaja](https://avatars.discourse-cdn.com/v4/letter/t/c6cbf5/32.png) [@thirumalairaja](https://forum.ansible.com/u/thirumalairaja)\
**Post date:** [December 15, 2023, 9:28am UTC](https://forum.ansible.com/t/need-to-test-ping/38628/3 "2023-12-15T09:28:04Z")

</div>

HI,

Thank you for correcting me  
i have some other issue related to this i hope you can help me on this,

I am using AWX tower and I created an Execution environment(which installed Packer and Terraform) to run my play book, i particularly use this task to confirm whether my ip is free or not.  
After my correction i am getting below error.

play:

- name: Ping the IP address  
ansible.builtin.command:  
cmd: ping -c 4 10.144.35.9  
register: ping\_result  
tags:
- ping

Error: ping: socket: Operation not permitted

---

<div class="post-metadata">

**Author:** ![Stu](https://avatars.discourse-cdn.com/v4/letter/s/3ec8ea/32.png) [@Stu](https://forum.ansible.com/u/Stu)\
**Post date:** [December 15, 2023, 11:50am UTC](https://forum.ansible.com/t/need-to-test-ping/38628/4 "2023-12-15T11:50:01Z")

</div>

Sounds like a permissions issue with the error you’ve got.  
Does it work if you elevate the user to root?

add

become: yes

to your play
