0

I am looking execute ping from localhost with delegate_to or local_action, which is not working in Ansible.

Tried with delegate_to and also with local_action.

---
  - name: sampleplaybook
    hosts: all
    become: yes
    become_user: root
    tasks:
     - name: ping check
       #shell: ping -c 1 -w 2 {{ ansible_host }}
       local_action: ping -c 1 -w 2 {{ ansible_host }}
       #delegate_to: localhost
       ignore_errors: true

But when I run the playbook, its still looking to establish ssh connection & failing. Anyway to fix it?

ansible-playbook sample.yml [WARNING]: Invalid characters were found in group names but not replaced, use -vvvv to see details

PLAY [sampleplaybook]


TASK [Gathering Facts] ************************************************************************************************************************************** The authenticity of host ' (IP#)' can't be established. ECDSA key fingerprint is SHA256:............................ ECDSA key fingerprint is MD5:........................... Are you sure you want to continue connecting (yes/no)? The authenticity of host ' (IP#)' can't be established.

vinWin
  • 509
  • 1
  • 5
  • 18
  • The host ansible runs on can't verify the remote host is actually the one your trying to reach. If you trust the connection you can disable strict host checking as described here: https://stackoverflow.com/questions/23074412/how-to-set-host-key-checking-false-in-ansible-inventory-file – jschuebel Nov 21 '22 at 07:56
  • 3
    Ansible's ping is **always** going to make you a SSH connection because it is a Python module run on the target, like any other module, see its synopsis: [_This is NOT ICMP ping, this is just a trivial test module that requires Python on the remote-node_](https://docs.ansible.com/ansible/latest/collections/ansible/builtin/ping_module.html#synopsis). – β.εηοιτ.βε Nov 21 '22 at 08:01
  • @β.εηοιτ.βε , True. Usure if we can disable with option from what @ jshuebel pointed towards. I tried options from the S.O post, but doesn't seem to help. – vinWin Nov 21 '22 at 08:20
  • @jschuebel , Not sure if it disabled ssh as its highlighted in second link.. – vinWin Nov 21 '22 at 08:21

0 Answers0