diff --git a/plugins/provisioners/ansible/provisioner.rb b/plugins/provisioners/ansible/provisioner.rb index 71d6fef1a..e353b5fed 100644 --- a/plugins/provisioners/ansible/provisioner.rb +++ b/plugins/provisioners/ansible/provisioner.rb @@ -26,7 +26,7 @@ module VagrantPlugins options << "--inventory-file=#{self.setup_inventory_file}" options << "--sudo" if config.sudo options << "--sudo-user=#{config.sudo_user}" if config.sudo_user - options << (config.verbose.to_s == "extra" ? "-vvv" : "--verbose") if config.verbose + options << "#{self.get_verbosity_argument}" if config.verbose options << "--ask-sudo-pass" if config.ask_sudo_pass options << "--tags=#{as_list_argument(config.tags)}" if config.tags options << "--skip-tags=#{as_list_argument(config.skip_tags)}" if config.skip_tags @@ -76,6 +76,18 @@ module VagrantPlugins return generated_inventory_file.to_s end + def get_verbosity_argument + if config.verbose.to_s =~ /^v+$/ + # Hopefully ansible-playbook accepts "silly" arguments like '-vvvvv', as '-vvv' + "-#{config.verbose}" + elsif config.verbose.to_s == 'extra' + '-vvv' + else + # fall back to default verbosity + '--verbose' + end + end + def as_list_argument(v) v.kind_of?(Array) ? v.join(',') : v end diff --git a/website/docs/source/v2/provisioning/ansible.html.md b/website/docs/source/v2/provisioning/ansible.html.md index b39f1c5dd..a8acef13b 100644 --- a/website/docs/source/v2/provisioning/ansible.html.md +++ b/website/docs/source/v2/provisioning/ansible.html.md @@ -122,7 +122,9 @@ These variables take the highest precedence over any other variables. by the sudo command. * `ansible.ask_sudo_pass` can be set to `true` to require Ansible to prompt for a sudo password. * `ansible.limit` can be set to a string or an array of machines or groups from the inventory file to further narrow down which hosts are affected. -* `ansible.verbose` can be set to `:extra` or `'extra'` to increase Ansible's verbosity to obtain full detailed logging (`-vvv`). Otherwise default verbosity level (`--verbose`) is applied. +* `ansible.verbose` can be set to increase Ansible's verbosity to obtain full detailed logging. By default, Vagrant uses Ansible default verbosity (`--verbose` or `-v`). By enabling this option following higher verbosity can be activated: + * `'vv'` + * `'vvv'`, also aliased as `'extra'` * `ansible.tags` can be set to a string or an array of tags. Only plays, roles and tasks tagged with these values will be executed. * `ansible.skip_tags` can be set to a string or an array of tags. Only plays, roles and tasks that *do not match* these values will be executed. * `ansible.start_at_task` can be set to a string corresponding to the task name where the playbook provision will start.