Merge branch 'more_ansible_options' of https://github.com/gildegoma/vagrant into gildegoma-more_ansible_options

Conflicts:
	plugins/provisioners/ansible/provisioner.rb
This commit is contained in:
Mitchell Hashimoto 2013-09-02 15:30:49 -07:00
commit 89ecb7850f
2 changed files with 31 additions and 0 deletions

View File

@ -9,6 +9,12 @@ module VagrantPlugins
attr_accessor :sudo
attr_accessor :sudo_user
attr_accessor :verbose
attr_accessor :tags
attr_accessor :skip_tags
attr_accessor :start_at_task
# Joker attribute, used to pass unsupported arguments to ansible anyway
attr_accessor :raw_arguments
def initialize
@playbook = UNSET_VALUE
@ -19,6 +25,10 @@ module VagrantPlugins
@sudo = UNSET_VALUE
@sudo_user = UNSET_VALUE
@verbose = UNSET_VALUE
@tags = UNSET_VALUE
@skip_tags = UNSET_VALUE
@start_at_task = UNSET_VALUE
@raw_arguments = UNSET_VALUE
end
def finalize!
@ -30,6 +40,10 @@ module VagrantPlugins
@sudo = nil if @sudo == UNSET_VALUE
@sudo_user = nil if @sudo_user == UNSET_VALUE
@verbose = nil if @verbose == UNSET_VALUE
@tags = nil if @tags == UNSET_VALUE
@skip_tags = nil if @skip_tags == UNSET_VALUE
@start_at_task = nil if @start_at_task == UNSET_VALUE
@raw_arguments = nil if @raw_arguments == UNSET_VALUE
end
def validate(machine)

View File

@ -3,8 +3,13 @@ module VagrantPlugins
class Provisioner < Vagrant.plugin("2", :provisioner)
def provision
ssh = @machine.ssh_info
inventory_file_path = self.setup_inventory_file
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
options << "--inventory-file=#{inventory_file_path}"
options << "--ask-sudo-pass" if config.ask_sudo_pass
@ -36,6 +41,12 @@ module VagrantPlugins
options << (config.verbose.to_s == "extra" ? "-vvv" : "--verbose")
end
# Append Provisioner options (higher precedence):
options << "--tags=#{as_list_argument(config.tags)}" if config.tags
options << "--skip-tags=#{as_list_argument(config.skip_tags)}" if config.skip_tags
options << "--limit=#{as_list_argument(config.limit)}" if config.limit
options << "--start-at-task=#{config.start_at_task}" if config.start_at_task
# Assemble the full ansible-playbook command
command = (%w(ansible-playbook) << options << config.playbook).flatten
@ -74,6 +85,12 @@ module VagrantPlugins
return generated_inventory_file.to_s
end
protected
def as_list_argument(v)
v.kind_of?(Array) ? v.join(',') : v
end
end
end
end