gpt4 book ai didi

ubuntu - Ansible本地配置文件无法识别 key ?

转载 作者:行者123 更新时间:2023-12-04 18:45:52 26 4
gpt4 key购买 nike

我有一个 vagrant带有 precise32 的盒子启动并运行。

我在~/Workspace/vagrans/ansible有文件的文件夹ansible.cfg带有以下条目:

[defaults]
inventory = ./dms/dev
private_key_file = /home/pkaramol/Workspace/vagrans/vagrant/precise32/.vagrant/machines/default/virtualbox/private_key

这有效:
ansible -m ping all --private-key=/home/pkaramol/Workspace/vagrans/vagrant/precise32/.vagrant/machines/default/virtualbox/private_key -u vagrant
tsrv1 | SUCCESS => {
"changed": false,
"ping": "pong"
}

这不会:
ansible-playbook playbooks/testplay.yml 

PLAY ***************************************************************************

TASK [setup] *******************************************************************
fatal: [tsrv1]: UNREACHABLE! => {"changed": false, "msg": "ERROR! SSH encountered an unknown error during the connection. We recommend you re-run the command using -vvvv, which will enable SSH debugging output to help diagnose the issue", "unreachable": true}

PLAY RECAP *********************************************************************
tsrv1 : ok=0 changed=0 unreachable=1 failed=0

这是剧本:
- hosts: testservers
tasks:
- name: just pinging
ping:

这是库存文件
[testservers]
tsrv1

我一定是错过了什么(?)......

最佳答案

无需像 you suggested 那样在配置文件和 playbook 之间拆分凭据.

您可以使用 remote-user ansible.cfg 中的参数在 private_key_file 旁边:

[defaults]
inventory = ./dms/dev
remote-user = vagrant
private_key_file = /home/pkaramol/Workspace/vagrans/vagrant/precise32/.vagrant/machines/default/virtualbox/private_key

关于ubuntu - Ansible本地配置文件无法识别 key ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41467529/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com