ssh - 我可以在命令行上覆盖 Ansible SSH key list 变量 ansible_ssh_private_key_file 吗?

标签 ssh ansible ssh-keys ansible-inventory

在 Ansible 2.4.2.0 中,我可以使用 ansible_ssh_private_key_file 覆盖 list 中设置的 SSH key 吗?在命令行上? --private-key 不可能对此问题报告的选项:Command-line flags (variable weight) not respected (bug or a feature?)

库存文件:

[group1]
instance1   ansible_host=host1  ansible_user=user1  ansible_ssh_private_key_file=~/.ssh/user1host1-id_rsa

命令行:
ansible-playbook playbook1.yml --private-key=some_other-id_rsa

最佳答案

您可以使用 --extra-vars 覆盖任何变量参数其中takes the priority over variables defined in any other place :

ansible-playbook playbook1.yml --extra-vars="ansible_ssh_private_key_file=some_other-id_rsa"

关于ssh - 我可以在命令行上覆盖 Ansible SSH key list 变量 ansible_ssh_private_key_file 吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50526418/

相关文章:

Ansible云信息模块

ubuntu - 使用 Ansible 将 ssh-id 从远程主机复制到另一个主机

python - 从字符串中获取后如何在paramiko中包含私钥?

没有 ssh-add 的 ssh key 转发

linux - WAN 上的 SSH 远程登录失败,但 lan 上的登录可以

ansible - 在 Ansible 中,如何在模板的 list 文件中使用变量

ubuntu - ssh heroku 错误 "PTY allocation request failed on channel 0 "

python - 在 python 中为基于文本的多人游戏创建安全终端环境的最佳方法

php - 尽管权限正确,Web PHP 实例仍无法运行可执行文件

ansible - 将整数变量传递给任务而不会丢失整数类型