【问题标题】:Can I override Ansible SSH key inventory variable ansible_ssh_private_key_file on command line?我可以在命令行上覆盖 Ansible SSH 密钥库存变量 ansible_ssh_private_key_file 吗?
【发布时间】:2018-11-04 16:32:20
【问题描述】:

在 Ansible 2.4.2.0 中,我可以在命令行中使用 ansible_ssh_private_key_file 覆盖清单中设置的 SSH 密钥吗?在此问题上报告的--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

【问题讨论】:

  • 您链接的主题中有答案。

标签: ssh ansible ssh-keys ansible-inventory


【解决方案1】:

您可以使用--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"

【讨论】:

  • 哦,当然,我在问题跟踪页面上看到了关于-e的讨论,但没有意识到hosts.ini中的ansible_ssh_private_key_file毕竟只是一个变量!谢谢!
猜你喜欢
  • 2016-05-01
  • 2016-12-04
  • 1970-01-01
  • 1970-01-01
  • 2018-12-27
  • 2018-02-27
  • 2021-05-13
  • 1970-01-01
  • 2016-11-15
相关资源
最近更新 更多