Ansible galaxy provisionner在Vagrant中没有使用私钥

all*_*mon 5 git ssh-keys vagrant ansible ansible-galaxy

我有以下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
Run Code Online (Sandbox Code Playgroud)

requirements.yml参考一些私人ansible角色,即是混帐克隆

像这样

- src: git@gitlab.mydomain.com:ansible-roles/myrole.git
  scm: git
  version: 'master'
  name: myrole
Run Code Online (Sandbox Code Playgroud)

我正在流浪者中注入我的桌面私钥

  • 它适用于销售提供商
  • 如果我vagrant ssh在机器内部后,它可以工作

但它不适用于带有错误的ansible_local配置程序

==> 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.
Run Code Online (Sandbox Code Playgroud)

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