From 66715de2aedc40daf405624012b5be7783b91e01 Mon Sep 17 00:00:00 2001 From: Gilles Cornu Date: Mon, 6 May 2013 22:28:20 +0200 Subject: [PATCH] Add a Joker to pass raw options to ansible-playbook call --- plugins/provisioners/ansible/config.rb | 5 +++++ plugins/provisioners/ansible/provisioner.rb | 6 ++++++ 2 files changed, 11 insertions(+) diff --git a/plugins/provisioners/ansible/config.rb b/plugins/provisioners/ansible/config.rb index 98dfb73a7..35c972877 100644 --- a/plugins/provisioners/ansible/config.rb +++ b/plugins/provisioners/ansible/config.rb @@ -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) diff --git a/plugins/provisioners/ansible/provisioner.rb b/plugins/provisioners/ansible/provisioner.rb index d84f714dd..1f51d5323 100644 --- a/plugins/provisioners/ansible/provisioner.rb +++ b/plugins/provisioners/ansible/provisioner.rb @@ -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