如何在ansible清单文件中设置host_key_checking=false? [英] How to set host_key_checking=false in ansible inventory file?
问题描述
我想使用 ansible-playbook
命令而不是vagrant provision
".但是,在 hosts
文件中设置 host_key_checking=false
似乎不起作用.
#hosts 文件vagrant ansible_ssh_private_key_file=~/.vagrant.d/insecure_private_keyansible_ssh_user=流浪 ansible_ssh_port=2222 ansible_ssh_host=127.0.0.1host_key_checking=false
在 Vagrantfile
之外是否有一个配置变量可以覆盖这个值?
由于我在 2014 年回答过这个问题,所以我更新了我的答案以考虑到最新版本的 ansible.
em>
是的,您可以在主机/库存级别执行此操作(这在 较新的 ansible 版本) 或全局级别:
库存:
添加以下内容.
ansible_ssh_common_args='-o StrictHostKeyChecking=no'
主持人:
添加以下内容.
ansible_ssh_extra_args='-o StrictHostKeyChecking=no'
hosts/inventory 选项适用于连接类型 ssh
而不是 paramiko
.有些人可能会强烈认为库存和主机更安全,因为范围更有限.
全局:
您可以在
/etc/ansible/ansible.cfg
或~/.ansible.cfg
文件中执行此操作:[默认值]host_key_checking = False
或者您可以设置和 env 变量(这可能不适用于较新的 ansible 版本):
导出 ANSIBLE_HOST_KEY_CHECKING=False
I would like to use ansible-playbook
command instead of 'vagrant provision
'. However setting host_key_checking=false
in the hosts
file does not seem to work.
# hosts file
vagrant ansible_ssh_private_key_file=~/.vagrant.d/insecure_private_key
ansible_ssh_user=vagrant ansible_ssh_port=2222 ansible_ssh_host=127.0.0.1
host_key_checking=false
Is there a configuration variable outside of Vagrantfile
that can override this value?
Due to the fact that I answered this in 2014, I have updated my answer to account for more recent versions of ansible.
Yes, you can do it at the host/inventory level (Which became possible on newer ansible versions) or global level:
inventory:
Add the following.
ansible_ssh_common_args='-o StrictHostKeyChecking=no'
host:
Add the following.
ansible_ssh_extra_args='-o StrictHostKeyChecking=no'
hosts/inventory options will work with connection type ssh
and not paramiko
. Some people may strongly argue that inventory and hosts is more secure because the scope is more limited.
global:
Ansible User Guide - Host Key Checking
You can do it either in the
/etc/ansible/ansible.cfg
or~/.ansible.cfg
file:[defaults] host_key_checking = False
Or you can setup and env variable (this might not work on newer ansible versions):
export ANSIBLE_HOST_KEY_CHECKING=False
这篇关于如何在ansible清单文件中设置host_key_checking=false?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!