Ping Ansible module not working

Hi,

I have done generating ssh key on the ansible host and copied it into app servers. But ping does not work. Please see below screenshot.

These are the steps that I have done:

ssh-keygen -t rsa
ssh tony@stapp01 mkdir -p .ssh
cat /home/thor/.ssh/id_rsa.pub | ssh tony@stapp01 ‘cat >> .ssh/authorized_keys’
ssh tony@stapp01 “chmod 700 .ssh; chmod 640 .ssh/authroized_keys”
ssh tony@stapp01

Iam successful upto doing ssh without password. But the command

ansible -m ping stapp01 does not work, how do I use that inventory file to make the
ping work. Please help.

Just cd to your inventory file dir and use “ansible stapp01 -m ping -i inventory” command as shown below

thor@jump_host /$ cd /home/thor/ansible/
thor@jump_host ~/ansible$ ansible stapp01 -m ping -i inventory
stapp01 | SUCCESS => {
    "ansible_facts": {
        "discovered_interpreter_python": "/usr/bin/python"
    },
    "changed": false,
    "ping": "pong"
}
thor@jump_host ~/ansible$