provisioners/ansible: Put ssh key in the inventory
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 <lpabon@redhat.com>
This commit is contained in:
parent
d29487a2bc
commit
f0718d620d
|
@ -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.")
|
||||
|
|
Loading…
Reference in New Issue