Merge branch 'generate_ansible_hosts' of https://github.com/commandtab/vagrant into commandtab-generate_ansible_hosts
Conflicts: plugins/provisioners/ansible/provisioner.rb
This commit is contained in:
commit
8445308830
|
@ -3,9 +3,9 @@ module VagrantPlugins
|
||||||
class Provisioner < Vagrant.plugin("2", :provisioner)
|
class Provisioner < Vagrant.plugin("2", :provisioner)
|
||||||
def provision
|
def provision
|
||||||
ssh = @machine.ssh_info
|
ssh = @machine.ssh_info
|
||||||
|
inventory_file_path = self.setup_inventory_file
|
||||||
options = %W[--private-key=#{ssh[:private_key_path]} --user=#{ssh[:username]}]
|
options = %W[--private-key=#{ssh[:private_key_path]} --user=#{ssh[:username]}]
|
||||||
options << "--inventory-file=#{config.inventory_path}" if config.inventory_path
|
options << "--inventory-file=#{inventory_file_path}"
|
||||||
options << "--ask-sudo-pass" if config.ask_sudo_pass
|
options << "--ask-sudo-pass" if config.ask_sudo_pass
|
||||||
|
|
||||||
if config.extra_vars
|
if config.extra_vars
|
||||||
|
@ -57,6 +57,19 @@ module VagrantPlugins
|
||||||
raise Vagrant::Errors::AnsiblePlaybookAppNotFound
|
raise Vagrant::Errors::AnsiblePlaybookAppNotFound
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def setup_inventory_file
|
||||||
|
return config.inventory_file if config.inventory_file
|
||||||
|
|
||||||
|
ssh = @machine.ssh_info
|
||||||
|
generated_inventory_file = "vagrant_ansible_inventory_#{machine.name}"
|
||||||
|
File.open(generated_inventory_file, 'w') do |file|
|
||||||
|
file.write("# Generated by Vagrant\n\n")
|
||||||
|
file.write("#{machine.name} ansible_ssh_host=#{ssh[:host]} ansible_ssh_port=#{ssh[:port]}\n")
|
||||||
|
end
|
||||||
|
|
||||||
|
return generated_inventory_file
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue