Add a Joker to pass raw options to ansible-playbook call

This commit is contained in:
Gilles Cornu 2013-05-06 22:28:20 +02:00
parent 7bc6dd8a33
commit 66715de2ae
2 changed files with 11 additions and 0 deletions

View File

@ -11,6 +11,9 @@ module VagrantPlugins
attr_accessor :verbose
attr_accessor :tags
# Joker attribute, used to pass unsupported arguments to ansible anyway
attr_accessor :raw_arguments
def initialize
@playbook = UNSET_VALUE
@extra_vars = UNSET_VALUE
@ -21,6 +24,7 @@ module VagrantPlugins
@sudo_user = UNSET_VALUE
@verbose = UNSET_VALUE
@tags = UNSET_VALUE
@raw_arguments = UNSET_VALUE
end
def finalize!
@ -33,6 +37,7 @@ module VagrantPlugins
@sudo_user = nil if @sudo_user == UNSET_VALUE
@verbose = nil if @verbose == UNSET_VALUE
@tags = nil if @tags == UNSET_VALUE
@raw_arguments = nil if @raw_arguments == UNSET_VALUE
end
def validate(machine)

View File

@ -4,7 +4,13 @@ module VagrantPlugins
def provision
ssh = @machine.ssh_info
# Connect with Vagrant user (unless --user or --private-key are overidden by 'raw_arguments')
options = %W[--private-key=#{ssh[:private_key_path]} --user=#{ssh[:username]}]
# Joker! Not (yet) supported arguments can be passed this way.
options << "#{config.raw_arguments}" if config.raw_arguments
# Append Provisioner options (higher precedence):
options << "--extra-vars=" + config.extra_vars.map{|k,v| "#{k}=#{v}"}.join(' ') if config.extra_vars
options << "--inventory-file=#{config.inventory_file}" if config.inventory_file
options << "--ask-sudo-pass" if config.ask_sudo_pass