Merge pull request #2667 from gildegoma/bugfix_ansible_raw_args

provisioner/ansible: Fix a bug in `raw_arguments` option
This commit is contained in:
Mitchell Hashimoto 2013-12-16 13:15:30 -08:00
commit 042a8d6428
2 changed files with 6 additions and 2 deletions

View File

@ -11,7 +11,7 @@ module VagrantPlugins
options = %W[--private-key=#{ssh[:private_key_path][0]} --user=#{ssh[:username]}] options = %W[--private-key=#{ssh[:private_key_path][0]} --user=#{ssh[:username]}]
# Joker! Not (yet) supported arguments can be passed this way. # Joker! Not (yet) supported arguments can be passed this way.
options << "#{config.raw_arguments}" if config.raw_arguments options.concat(self.as_array(config.raw_arguments)) if config.raw_arguments
# Append Provisioner options (highest precedence): # Append Provisioner options (highest precedence):
options << "--inventory-file=#{self.setup_inventory_file}" options << "--inventory-file=#{self.setup_inventory_file}"
@ -123,6 +123,10 @@ module VagrantPlugins
def as_list_argument(v) def as_list_argument(v)
v.kind_of?(Array) ? v.join(',') : v v.kind_of?(Array) ? v.join(',') : v
end end
def as_array(v)
v.kind_of?(Array) ? v : [v]
end
end end
end end
end end

View File

@ -143,7 +143,7 @@ by the sudo command.
* `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.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.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. * `ansible.start_at_task` can be set to a string corresponding to the task name where the playbook provision will start.
* `ansible.raw_arguments` is an *unsafe wildcard* string that can be used to take advantage of `ansible-playbook` arguments that are not (yet) supported by this Vagrant provisioner plugin. This can be very useful when integrating with bleeding edge Ansible versions. Following precedence rules apply: * `ansible.raw_arguments` can be set to an array of strings corresponding to a list of `ansible-playbook` arguments (e.g. `['--check', '-M /my/modules']`). It is an *unsafe wildcard* that can be used to apply Ansible options that are not (yet) supported by this Vagrant provisioner. Following precedence rules apply:
* Any supported options (described above) will override conflicting `raw_arguments` value (e.g. `--tags` or `--start-at-task`) * Any supported options (described above) will override conflicting `raw_arguments` value (e.g. `--tags` or `--start-at-task`)
* Vagrant default user authentication can be overridden via `raw_arguments` (with custom values for `--user` and `--private-key`) * Vagrant default user authentication can be overridden via `raw_arguments` (with custom values for `--user` and `--private-key`)
* `ansible.groups` can be used to pass a hash of group names and group members to be included in the generated inventory file. For example: * `ansible.groups` can be used to pass a hash of group names and group members to be included in the generated inventory file. For example: