Commit Graph

788 Commits

Author SHA1 Message Date
Brian Cain 84f929df21
Merge pull request #9351 from gclinch/salt-bootstrap-in-tmp
Change to a temporary directory before downloading script files
2018-02-09 11:14:17 -08:00
Chris Roberts 3664f1a627 Allow hiding environment variable values in shell provisioner 2018-01-12 17:33:47 -08:00
Graham Clinch b384361cd2 Use the short flag for better cross-platform support 2018-01-09 17:58:20 +00:00
Graham Clinch 1c2929cd84 Change to a temporary directory before downloading script files, to avoid
leaving junk files in the working directory (probably ~vagrant)
2018-01-09 16:01:50 +00:00
Gilles Cornu 43bcf2aaf7
Merge pull request #9173 from hashicorp/gildegoma/fix-ansible-ask-sudo-pass-deprecation
Ansible Provisioner: Fix broken 'ask_sudo_pass' option
2017-12-14 21:46:23 +01:00
Brian Cain a724a19a5d
Merge pull request #8992 from BenjaminSchiborr/fix/master/fix_salt_windows_bootstrap
provisioners/salt: Fixes timeout issue in salt bootstrapping for windows
2017-12-07 11:27:55 -08:00
Gilles Cornu e47deb7fd0
ansible: Fix broken 'ask_sudo_pass' option
This bug (invalid method call) hasn't been caught by unit tests because
Vagrant::Plugin::V2::Config catches all invalid/bad configuration calls
and save them for generating error messages during the "validate" stage.
This way, the `ask_sudo_pass=(value)` method was not interrupted and the
`@ask_become_pass` attribute was (surprisingly) correctly set (allowing
the related unit tests to pass).

In order to avoid similar problem to happen again, the deprecation
message output is now fully verified.
2017-11-09 18:17:04 +01:00
Benjamin Schiborr ee800cc7c2 provisioners/salt: #8991: Break if success
This commit ensures that we actually break when the download was
successful. Before it tried to download again for every iteration of the
loop. In addition the number of iterations have been increased. I've
experienced timeouts on third retry. Increasing to 5.
2017-11-06 13:56:11 -08:00
Adam Bolte 511fac8162
Attempt fetching salt bootstrap script with wget
On Debian installations, wget is installed even into the most minimal
environment. Even Python support on Debian cannot be guaranteed if
Standard System Utilities was not selected at installation time (or if
debootstrap was used), which is why the retrieved bootstrap-salt.sh
script takes care of installing it prior to installing Salt.
2017-10-26 13:41:40 +11:00
Vít Ondruch 7187e6f909 Use Integer instead of Fixnum for Ruby 2.4+ compatibility. 2017-10-23 10:57:36 -07:00
Brian Cain c88ccb0b3d Merge pull request #9014 from benh57/winssh_puppet_fix
Fix winssh communicator support in puppet provisioner
2017-10-10 09:46:59 -07:00
Jonathan LaBroad 56861296fa Added tests and validation for python_version parameter 2017-10-05 06:25:36 -04:00
Jonathan LaBroad 3524eb9ef4 Merge remote-tracking branch 'upstream/master' 2017-10-04 14:59:57 -04:00
Brian Cain fb1501d48a Merge pull request #8874 from taliesins/HandleChefProvisionerRebootRequest
Handle chef provisioner reboot request
2017-10-04 09:37:02 -07:00
Ben Hines e133547932 Properly call winssh communicator on windows via powershell, and fix syntax for powershell via puppet. 2017-09-29 20:53:09 -07:00
Benjamin Schiborr c30c00508c provisioners/salt: #8991: Fixes timeout issue in salt bootstrapping for windows
Fixes #8991.

1. When remote executing scripts one should always call powershell with
1a. "-NonInteractive", in order to prevent interactive prompts from leading to an endless waiting time for the script to return
1b. "-NoProfile", in order to prevent the loading of unknown custom profiles before execution of the script which could have unintended side effects
2. During my tests I constantly ran into 408 timeouts when downloading the salt binaries. I've prevented that by adding a simple retry mechanism and an error exit in case of multiple failures. Without this change the bootstrap script never returned (and neither did vagrant up)
2017-09-22 18:08:30 -07:00
Mikhail Bulash 508d94d466 provisioners/shell: Use ui.detail for displaying output
Output format of ui.info method (bold text) makes reading long script outputs really heavy on the eyes. ui.detail is a better match for this type of output.
2017-09-18 17:55:07 +03:00
Jonathan LaBroad 6f53c3991c Merge remote-tracking branch 'upstream/master' 2017-09-11 09:15:22 -04:00
Chris Roberts 34addec796 Merge pull request #8913 from mitchellh/gildegoma/6570-ansible-compatibility-mode
Ansible: Add "compatibility_mode" and "*become*" common options; Move "version" to common options
2017-09-06 13:18:08 -07:00
Gilles Cornu ac75e409a3
provisioners/ansible(both): Quote host_vars if needed
This patch is based on @subimage's inputs in the related GitHub issue.
Thanks again!

Fix #8597
2017-09-06 21:22:41 +02:00
Gilles Cornu a0a09c6095
minor: Fix a typo in a code comment
[ci skip]
2017-09-06 17:12:51 +02:00
Gilles Cornu 4dc3e59b08
provisioners/ansible(both): Review of PR #8913
- Keep the Programming Errors with corresponding Exception class and
  en.yml message template. Fix the alphabetical order in errors.rb by
  the way.
- Fix English wording in the documentation and en.yml messages
- Use StandardError for unknown error rescuing.

Thanks @chrisroberts!
2017-09-06 17:12:50 +02:00
Gilles Cornu 6bc0c85e90
provisioners/ansible_local: Optimize SSH commands
With this change, the same remote command is used to:
- verify that ansible is available
- gather the ansible version details
2017-09-06 17:12:46 +02:00
Gilles Cornu 9996ed6259
provisioners/ansible_local: Fix an obsolete comment
[ci skip]
2017-09-06 17:12:44 +02:00
Gilles Cornu dc3b6341e2
provisioners/ansible: Check compatibility conflicts
Vagrant will verify that the current Ansible version does support the
requested compatibility mode (only applicable if not "auto", of course).

As mentioned in the documentation, there is no sanity checks between
`version` option and `compatibility_mode` option.

With this change, the host-based provisioner is also improved to
execute only once the "ansible" command (and store the gathered
information for multiple usages like version requirement and
compatibility checks). On the other hand, the guest-based provisioner
can still potentially execute "ansible" twice (once in the
AnsibleInstalled cap, and via "gather_ansible_version" function via
Base::set_compatibility_mode).
2017-09-06 17:12:40 +02:00
Gilles Cornu 36616fb208
provisioners/ansible: Add @control_machine instance variable
This minor addition will be used for upcoming shared code in base
superclass and avoid "guest"/"host" repetitions.
2017-09-06 17:12:39 +02:00
Gilles Cornu 8c0df3d046
provisioners/ansible: Move `version` to common options
Before this change, only the ansible_local provisioner supported this
option (for ansible version requirement, and pip installation). Now, the
ansible host-based provisioner can also require a exact ansible version.

Resolve #8914

Note: this has been added as part of #6570 resolution, since the
introduction of the `compatibility_mode` auto-detection made both
provisioners made capable to detect ansible version.

Pending: optimize the code to avoid duplicated executions of "ansible
--version" command.
2017-09-06 17:12:35 +02:00
Gilles Cornu a327e34861
provisioners/ansible: Validate compatibility_mode
- Use `'auto'` instead of `nil` for the auto-detection mode
- Add strict validation and related error message
2017-09-06 17:12:32 +02:00
Gilles Cornu 8834afbd8e
provisioners/ansible(both): Add compatibility mode
With this change, it is now possible to get rid of many deprecation
messages successively introduced in Ansible 1.9, and 2.0. More
interesting, the generated inventory will contain the recommended
variable names (e.g. `ansible_host` instead of `ansible_ssh_host`)
when the compatibility mode is set to '2.0'.

Details:

- Add `compatibility_mode` option to control the Ansible parameters
  format to be used. The value corresponds to the minimal version
  supported. For the moment, possible values are '1.8' (corresponding to
  Vagrant's former behaviour) or '2.0'.
  Note that a dynamic inventory generated in compatibility mode '2.0'
  is not supported by Ansible 1.x. On the other hand, Ansible 2.x so far
  supports inventory format generated by the compatibility mode '1.8'.

- Add compatibility mode auto-detection, based on the available Ansible
  version. This is the default behaviour in order to bring a maximum of
  user friendliness. The drawback of this approach is to let potential
  compatibility breaking risks, for `ansible` provisioner setups that
  already integrate Ansible 2.x **AND** rely on the existence of
  the generated `_ssh` variable names. Thanks to the vagrant warnings
  (and its release notes), I argue that it is worth to offer
  auto-detection by default, which offers a sweet transition to most
  users.

- Add `become`, `become_user` and `ask_become_pass` options and their
  backwards compatible aliases. The legacy options are now deprecated.

Note that we intentionally didn't provide a '1.9' compatibility mode,
as it would add extra-complexity for practically no added-value.
To my knowledge, the Ansible 2.x series haven't introduced yet any major
changes or deprecations that would motivate to introduce a higher
version compatibility mode (to be confirmed/verified).

Resolve GH-6570

Still Pending:

- Optimization: Reduce the number of `ansible` command executions.
  Currently two exec calls will be performed when the compatibility
  mode auto-detection is enabled (i.e. by default). We could make the
  provisioner a little bit smarter to only execute `ansible` only once
  in any situation (by combining "presence" and "version" checks).

- User-friendliness: Add better validator on `compatibility_mode`
  option, and shows a warning or an error instead of the silent
  fallback on the auto-detection modus.

- Test coverage: All the added behaviours are not fully covered yet.
2017-09-06 17:12:22 +02:00
Gilles Cornu e09848ca59
provisioners/ansible_local: Shellescape extra-vars
Fix #7735

Further work for proper shell-escaping of other ansible-playbook and
ansible-galaxy command line arguments will be addressed via #8949.
2017-09-06 16:30:40 +02:00
Brian Cain 089117bc0f Merge pull request #8939 from briancain/8933/master/source-path-file-prov
Align file provisioner functionality on all platforms
2017-09-05 15:54:52 -07:00
Gilles Cornu b741ff7999
provisoners/ansible(both): Accept 'all:vars'
The patterns "all" is a special keyword that target all hosts in the
inventory. Therefore it makes sense to accept "all:vars" as a group
variable name. Note that "*:vars" pattern is not valid in an Ansible
inventory.
See http://docs.ansible.com/ansible/latest/intro_patterns.html#patterns

Fix #7730
2017-09-03 18:41:06 +02:00
Brian Cain a9564b2137 (#8933) Align file provisioner functionality on all platforms
This commit aligns how the file provisioner should work on all host
machines. It ensures that a `/.` is only applied if the user intended
to upload a folder to a destination under a different name. It ensures
that if uploading to a windows guest with a different destination folder
name, it does not nest the source folder under that name so that it
works the same as it does on linux platforms. It also updates the
behavior of the winrm upload communicator by allowing an array of paths
to be uploaded instead of a single file or folder to allow for this new
functionality for windows guests.
2017-08-31 15:57:53 -07:00
Brian Cain 432cb8d915 (#7826) Add salt_arg option for passing flags to salt tool
This commit introduces the salt_arg option that allows a user to pass
additional command line flags to the `salt` tool when provisioning with
a master setup.

It also adds additional config validation to ensure that both
`salt_args` and `salt_call_args` is an array.
2017-08-29 14:11:06 -07:00
Brian Cain 9a29d7be6b (#7836) Introduce salt_call_args option for salt provisioner
This config option for the salt provisioner allows you to pass
additional arguments to the salt-call executable.
2017-08-29 11:17:29 -07:00
Jonathan LaBroad 8e2c66d8a8 Reverting whitespace change 2017-08-29 13:23:53 -04:00
Jonathan LaBroad 8e3831b810 Update default minion version to latest (Python 2)
Perform check to determine to include python version or not
2017-08-29 13:13:24 -04:00
Jonathan LaBroad 384848e92d Adding python_version parameter for Windows minions
Ignoring non-Windows Salt parameters
Get the correct minion file for ver >= 2017.x.x
2017-08-29 12:38:29 -04:00
Peter Parkkali 8e4f0444e8 Hide duplicate errors in Saltstack provisioner when verbose mode is on 2017-08-26 01:38:06 +02:00
Brian Cain c0b54f74ea Merge pull request #8875 from briancain/8716/master/dup-string-if-frozen-for-line-endings
Dup string if frozen for line endings
2017-08-15 10:04:34 -07:00
Brian Cain 01528689fd (#8716) Dup string if frozen for line endings
Prior to this commit, if a user passed in a script that was frozen,
the shell provisioner would fail to modify the script to replace line
endings for windows because the string was immutable. This commit fixes
that by dup'ing the string so that it can have its line endings replaced
2017-08-15 08:38:30 -07:00
Brian Cain 61c501cc65 Ensure paths with spaces are preserved
Prior to this commit, if a user set the `destination` path to include a
space, the `shell_expand_guest_path` function would remove that space
and return a partial path. This commit updates that to quote the path to
be expanded to preserve the entire path.
2017-08-14 15:34:10 -07:00
Brian Cain 40eaef08b7 (#8603) Ensure remote folder exists prior to scp in file provisioner
Prior to this commit, if a file provisioner block was ran twice with a
folder on a remote host, due to how scp works, it would first copy over
that folder, and then on the second action it would copy an identical
folder nested within the first one. While this is 'intended' behavior
with scp, it is unexpected behavior for the file provisioner. This
commit updates the file provisioner to first ensure that the directory
to be copied exists on the remote host prior to copying, and then the
destination dir has been changed to the directory that the destination
will be copied to, rather than the exact directly that includes the
folder from the host to prevent the nested folder behavior.
2017-08-11 11:49:39 -07:00
Taliesin Sisson 3ab64ab7e4 Handle Chef provisioner requests to reboot. A request to reboot is not a convergence failure, so don't treat it like a convergence failure.
Wait for the machine to reboot before trying to continue the provisioning.
2017-08-10 11:39:41 +01:00
Brian Cain 7a7506cd00 (#8789) Remove curl pipe bash install for salt provisioner
Prior to this commit, because of how the bootstrap salt shell file
worked, if github could not be resolved, the installer script would fail
silently with an exit code 0 because `sh` would evalute without any
errors and the curl exit code would be ignored. This commit splits out
the installer to first attempt to save the bash installer, and if it
exists, execute it.
2017-08-09 10:23:13 -07:00
Brian Cain 623b117208 Merge pull request #8682 from Telekom-PD/omnibus-url
Add config option omnibus_url for chef provisioners
2017-08-03 09:19:13 -07:00
Artem Sidorenko 875c2edc62 Add config option omnibus_url for chef provisioners
This option is useful for internal setups, where own customized
omnibus installation script is used (e.g. to get chef from a mirror)
2017-08-03 10:06:27 +02:00
Brian Cain a2d39742a7 Merge pull request #8775 from lucky-sideburn/master
Added exception if chef.node_path is defined on Vagrantfile but the directory does not exist locally
2017-08-01 13:22:23 -07:00
Eugenio Marzo 7e436c6971 fixed warnings about missing folders for Chef Solo and Zero 2017-08-01 21:37:11 +02:00
Eugenio Marzo c9b65bd129 produce error when node_path is defined but the directory does not exist on disk locally 2017-07-22 11:05:34 +02:00