We have a Python program that calls the ansible Python API -- e.g.:
```python
pb = ansible.playbook.PlayBook(
playbook=playbook,
host_list=host_list,
stats=stats,
callbacks=playbook_cb,
runner_callbacks=runner_cb,
extra_vars=extra_vars,
private_key_file=private_key_file,
subset=host
)
pb.run()
```
How can I specify that I want host_key_checking off?
There are a few things that work, but I'm trying to avoid for various
reasons:
1. Putting `host_key_checking = False` in ansible.cfg -- trying to avoid
this because the user could run our tool from any directory so we don't
know that ansible.cfg will be in their current directory and we don't want
to force them to have a ~/.ansible.cfg or /etc/ansible/ansible.cfg
2. Setting environment variable `ANSIBLE_HOST_KEY_CHECKING`. The following
works, but it's a little gross because it's messing with global state and
it has to be done before importing ansible for it to take effect:
```
os.environ['ANSIBLE_HOST_KEY_CHECKING'] = 'False'
import ansible.runner
import ansible.playbook
from ansible import callbacks
```
Is there some other way to just pass in a parameter or something to turn
off host key checking? It doesn't look like it from a quick scan of the
code. Wonder if a PR that added an optional parameter might be something
that would be considered?
Related:
https://groups.google.com/forum/#!msg/ansible-project/OuHJwG0LLTY/qp95qAq-PNUJ
--
You received this message because you are subscribed to the Google Groups
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/732df0b3-d37f-404e-8c64-a2404c0872ca%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.