provisioners/ansible: spare machine.ssh_info calls

As a result of #4670 and the safe decision to not memoize
machine.ssh_info (see 89a4a29d65 and
5036d16461), it is preferable to store the
ssh_info hashes and avoid multiple function calls when generating the
ansible inventory.
This commit is contained in:
Gilles Cornu 2014-10-23 22:58:01 +02:00
parent 5829c27048
commit 1e324093a5
1 changed files with 3 additions and 2 deletions

View File

@ -108,8 +108,9 @@ module VagrantPlugins
@machine.env.active_machines.each do |am| @machine.env.active_machines.each do |am|
begin begin
m = @machine.env.machine(*am) m = @machine.env.machine(*am)
if !m.ssh_info.nil? m_ssh_info = m.ssh_info
file.write("#{m.name} ansible_ssh_host=#{m.ssh_info[:host]} ansible_ssh_port=#{m.ssh_info[:port]}\n") if !m_ssh_info.nil?
file.write("#{m.name} ansible_ssh_host=#{m_ssh_info[:host]} ansible_ssh_port=#{m_ssh_info[:port]}\n")
inventory_machines[m.name] = m inventory_machines[m.name] = m
else else
@logger.error("Auto-generated inventory: Impossible to get SSH information for machine '#{m.name} (#{m.provider_name})'. This machine should be recreated.") @logger.error("Auto-generated inventory: Impossible to get SSH information for machine '#{m.name} (#{m.provider_name})'. This machine should be recreated.")