Disable host-key checking while using ansible adhoc command

If you want to disable host key checking for ansible adhoc command, first run the the command below.

 [root@server ~]# export ANSIBLE_HOST_KEY_CHECKING=False

Now, once you have disabled host key checking run your ansible ad-hoc command.

 [root@server ~]#  ansible all -i inventory -m shell -a 'uptime'

Run Ansible adhoc command with Sudo

[root@server ~]# ansible all -i inventory.yml -m shell -a 'service crond restart' -K --become

Leave a Reply

Your email address will not be published. Required fields are marked *