Commit Graph

12 Commits

Author SHA1 Message Date
Gilles Cornu b2286388f0 provisioners/ansible: add basic config validators
With this change, the `raw_arguments` and `raw_ssh_args` options are:
- STILL automatically converted as an Array when they are set a String
  (no behaviour change)
- rejected if they are not of Array data type otherwise

Additional Notes:
- the 'as_array' tiny helper has been removed since it was no longer
  used.
- there is for now no deeper validation (i.e. verifying that the Array
  elements are only *String* objects)
2016-04-20 23:54:19 +02:00
Gilles Cornu ab036ddd0b provisioners/ansible: don't format raw_arguments
With cb80286a4a, the helper function
stringify_ansible_playbook_command was also applied on the
`raw_arguments` content, which is not wanted. Given that users have used
the `raw_arguments` option as a workaround to avoid the bug GH-6726,
this new change ensure that any `--extra-vars` option passed as a raw
argument won't be additonally enquoted by the ansible_local
provisioner.

This change also improves the ansible remote provisioner verbose output,
but has no impact on its behaviour, which was already correct.

Note that this refactoring introduces some code duplications that are not
very elegant (see ansible_playbook_command_for_shell_execution in
host.rb and execute_ansible_playbook_from_host in base.rb). I hope we
can find a better implementation later, but it is good enough for now
since all these parts are covered by corresponding unit tests (the
`ansible_local` stuff being tested via the verbose output of the ansible
remote provisioner).
2016-04-20 23:50:42 +02:00
Gilles Cornu 4e451c6e99 provisioners/ansible_local: fix #6763
Before this change, the detection of a non-existing path on the guest
machine was considered as an error and lead to interrupt the current vagrant
action. This was actually a mistake to do so, since the config checks
are performed before many other vagrant actions than `provision`.
The config.validate phase is also intended to primarily check the options
sanity, but it cannot be too strict with the guest state (which can easily
get "out of automatic control").

With this change, we still apply these checks (when possible), but only warn
about possible configuration problems. This way, the subsequent
statements will happen anyway (e.g. ansible commands will be
executed, vagrant machine will be destroyed, etc.)
2016-01-17 11:27:23 +01:00
Gilles Cornu 1e38be237e provisioners/ansible: fix galaxy paths on Windows
Close #6757 and update previous fix for #6740 (#6741).

See also these places where the same regexp is used to address similar
"Windows cases":

 - ec85548bd6/plugins/provisioners/chef/provisioner/chef_solo.rb (L99-L103)
 - ec85548bd6/plugins/guests/windows/cap/rsync.rb (L6-L9)
2016-01-05 08:22:10 +01:00
char16t 07f3d0b00d Fix #6740: Ansible local provisioner: remove windows drive letter from path 2015-12-27 12:01:45 +03:00
Christian Henz 77b11a989c Implemented host_vars option. 2015-12-01 18:56:28 +01:00
Gilles Cornu 2384032446 provisioners/ansible: freeze a constant value
Kudos @sethvargo :)

[skip ci]
2015-11-20 00:21:41 +01:00
Gilles Cornu 5659c3f2a0 provisioners/ansible: apply @sethvargo comments
Follow-up of code review of PR #6529
2015-11-19 23:42:01 +01:00
Gilles Cornu c1f3d114f5 provisioners/ansible(both): add galaxy support
Close #2718
2015-11-17 22:08:29 +01:00
Gilles Cornu a0576349fe provisioners/ansible(both): reorganize i18n texts
These adaptations will make even more sense with the upcoming
introduction of `ansible-galaxy` support.
2015-11-17 22:08:18 +01:00
Gilles Cornu a3c077cbe0 Merge branch 'gildegoma/ansible-force-ssh-user'
Resolved conflicts in
  plugins/provisioners/ansible/config.rb
  plugins/provisioners/ansible/provisioner.rb
  test/unit/plugins/provisioners/ansible/provisioner_test.rb
  website/docs/source/v2/provisioning/ansible.html.md

ref #6348
2015-11-08 14:01:23 +01:00
Gilles Cornu 9bfdaf7e75 provisioners/ansible: introduce ansible_local
With this change, the existing host-based Ansible provisioner is
refactored to share a maximum of code with this new guest-based Ansible
provisioner.

At this stage of development, the existing unit tests are intentionally
modified as little as possible, to keep safe the existing funtionalities.

Other issues resolved by this changeset:
 - Display a warning when running from a Windows host [GH-5292]
 - Do not run `ansible-playbook` in verbose mode when the `verbose` option
   is set to an empty string.
2015-11-08 10:42:48 +01:00