Regarding How to set host_key_checking=false in ansible inventory file? I wanted to know if it is possible to change this setting on the playbook definition.
My playbook is called automatically and I cannot use export
to set the ENV variable before starting the playbook.
This is what I tried:
---
- hosts: localhost
environment:
ANSIBLE_HOST_KEY_CHECKING: false
roles:
- including_vars
The problem is that if I add a host during the playbook tasks I get the following error:
UNREACHABLE! => {"changed": false, "msg": "Failed to connect to the host via ssh: Host key verification failed.\r\n", "unreachable": true}
This seems to indicate that the environment variable is not used.
Any idea on how I could change this setting on runtime?