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.