need to test Ping

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

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

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

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