From f0718d620d49141d8d6f9f71a31c291f2b4fab55 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20Pab=C3=B3n?= Date: Sat, 20 Dec 2014 23:44:23 -0500 Subject: [PATCH] provisioners/ansible: Put ssh key in the inventory MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Vagrant 1.7.1 creates and injects new ssh keys for each virtual machine. When it started ansible with the "parallel provisioning trick", it would only send the ssh key of the targeted virtual machine. With this change, vagrant now stores the ssh key for each virtual machines directly in the generated ansible inventory, and thus allow ansible parallelism. Note that this change is not sufficient, as it would break vagrant configuration based on a custom inventory (file or script). This issue will be addressed in a next commit. Signed-off-by: Luis Pabón --- plugins/provisioners/ansible/provisioner.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/plugins/provisioners/ansible/provisioner.rb b/plugins/provisioners/ansible/provisioner.rb index 3d699ac57..022d02473 100644 --- a/plugins/provisioners/ansible/provisioner.rb +++ b/plugins/provisioners/ansible/provisioner.rb @@ -20,8 +20,8 @@ module VagrantPlugins # Ansible provisioner options # - # Connect with Vagrant SSH identity - options = %W[--private-key=#{@ssh_info[:private_key_path][0]} --user=#{@ssh_info[:username]}] + # By default, connect with Vagrant SSH username + options = %W[--user=#{@ssh_info[:username]}] # Connect with native OpenSSH client # Other modes (e.g. paramiko) are not officially supported, @@ -127,7 +127,7 @@ module VagrantPlugins m = @machine.env.machine(*am) m_ssh_info = m.ssh_info if !m_ssh_info.nil? - inventory += "#{m.name} ansible_ssh_host=#{m_ssh_info[:host]} ansible_ssh_port=#{m_ssh_info[:port]}\n" + inventory += "#{m.name} ansible_ssh_host=#{m_ssh_info[:host]} ansible_ssh_port=#{m_ssh_info[:port]} ansible_ssh_private_key_file=#{m_ssh_info[:private_key_path][0]}\n" inventory_machines[m.name] = m else @logger.error("Auto-generated inventory: Impossible to get SSH information for machine '#{m.name} (#{m.provider_name})'. This machine should be recreated.")