diff --git a/plugins/provisioners/ansible/config.rb b/plugins/provisioners/ansible/config.rb index beaea5466..98dfb73a7 100644 --- a/plugins/provisioners/ansible/config.rb +++ b/plugins/provisioners/ansible/config.rb @@ -9,6 +9,7 @@ module VagrantPlugins attr_accessor :sudo attr_accessor :sudo_user attr_accessor :verbose + attr_accessor :tags def initialize @playbook = UNSET_VALUE @@ -19,6 +20,7 @@ module VagrantPlugins @sudo = UNSET_VALUE @sudo_user = UNSET_VALUE @verbose = UNSET_VALUE + @tags = UNSET_VALUE end def finalize! @@ -30,6 +32,7 @@ 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 end def validate(machine) diff --git a/plugins/provisioners/ansible/provisioner.rb b/plugins/provisioners/ansible/provisioner.rb index 8891f0357..d84f714dd 100644 --- a/plugins/provisioners/ansible/provisioner.rb +++ b/plugins/provisioners/ansible/provisioner.rb @@ -8,15 +8,8 @@ module VagrantPlugins 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 - - if config.limit - if not config.limit.kind_of?(Array) - config.limit = [config.limit] - end - config.limit = config.limit.join(",") - options << "--limit=#{config.limit}" - end - + options << "--tags=#{as_list_argument(config.tags)}" if config.tags + options << "--limit=#{as_list_argument(config.limit)}" if config.limit options << "--sudo" if config.sudo options << "--sudo-user=#{config.sudo_user}" if config.sudo_user options << "--verbose" if config.verbose @@ -40,6 +33,12 @@ module VagrantPlugins raise Vagrant::Errors::AnsiblePlaybookAppNotFound end end + + private + + def as_list_argument(v) + v.kind_of?(Array) ? v.join(',') : v + end end end end