gpt4 book ai didi

git - Ansible galaxy provisionner 未在 Vagrant 中使用私钥

转载 作者:太空狗 更新时间:2023-10-29 13:27:12 26 4
gpt4 key购买 nike

我有以下 vagrantfile

Vagrant.configure(2) do |config|

config.ssh.insert_key = true
config.vm.define "dev" do |app|
app.vm.provider "docker" do |d|
d.image = "allansimon/allan-docker-dev-python"
d.has_ssh = true
end

app.ssh.username = "vagrant"

app.vm.provision "file", source: "~/.ssh/id_rsa", destination: ".ssh/id_rsa"


app.vm.provision "permits-root-to-clone", type: "shell" do |s|
s.inline = "cp /home/vagrant/.ssh/id_rsa /root/.ssh/id_rsa"
end
# if i put here a new shell provisionner , to the exact same repo than in my galaxy roles , it works

app.vm.provision "ansible_local" do |ansible|
ansible.galaxy_role_file = "build_scripts/ansible/requirements.yml"
ansible.playbook = "build_scripts/ansible/bootstrap.yml"
end
end
end

requirements.yml 引用了一些私有(private)的 ansible 角色,这些角色是 git 克隆的

像这样

- src: git@gitlab.mydomain.com:ansible-roles/myrole.git
scm: git
version: 'master'
name: myrole

我正在将我的桌面私钥注入(inject)到 vagrant 中

  • 它在销售供应商中工作
  • 如果我在机器内 vagrant ssh 之后它会工作

但它不适用于 ansible_local provisionner有错误

==> dev: Running provisioner: ansible_local...
dev: Running ansible-galaxy...
[WARNING]: - supervisord was NOT installed successfully: - command git clone
git@gitlab.mydomain.com:ansible-roles/myrole.git myrole failed in
directory /tmp/tmpQNgCTo (rc=128)
ERROR! - you can use --ignore-errors to skip failed roles and finish processing the list.
Ansible failed to complete successfully. Any error output should be
visible above. Please fix these errors and try again.

有没有办法强制 vagrant 中的 ansible 使用特定的私钥?

最佳答案

我认为这是因为 ssh 客户端要么无法找到您的私钥,要么无法在 vagrant 框中使用它(权限问题?)以用于对 git 存储库进行身份验证。您也许应该添加默认配置文件 (~/.ssh/config)。

这似乎已得到确认,因为当您使用 ssh 连接到 vagrant box 时,本地 ssh 客户端能够使用 ssh-agent 获取 key ,该 key 与您的连接一起转发台式机。

如果要手动调试

  • 在 vagrant box 中使用 ssh
  • 杀死 ssh-agent (ssh-agent -k)
  • 手动检索 git 存储库(git clone git@gitlab.mydomain.com:ansible-roles/myrole.git)或尝试直接使用 ssh(ssh git@gitlab.mydomain. com) 可以帮助
  • 找出错误

关于git - Ansible galaxy provisionner 未在 Vagrant 中使用私钥,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37989742/

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