-
Notifications
You must be signed in to change notification settings - Fork 155
Support for pre-configuring communicator transports (SSH or WinRM) via init_script setting #124
Conversation
This is basically an alternate solution for #120, which adds a way to deal with the requiretty issue (#115) while also adding support for Windows. This is also a lower level solution - which is good because the scripts can be customized (e.g. my WinRM solution uses self-signed certificates; some organizations might want to install a custom CA instead), but we might want higher-level options or auto-detection to decide if a commonly used I think a good option would be to use strings as a script, but to look up symbols from a collection of common scripts that are shipped with the gem. So you could use settings like: @smashwilson @mdarby: Can you review and also let me know about the comment above? |
end | ||
|
||
if config.init_script && communicator == :winrm | ||
# Might want to check init_script against known limits |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
☝️ I'd say, keep it as letting the API validate the script length. That way we're insulated from configuration or account changes that would alter the limits. There would be nothing more annoying than having your account adjusted to allow a larger init script, but have Vagrant shut you down before it even tries the call.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's the problem, the API doesn't validate the script length. It does't fail either - it just ignores the script but boots the server.
In the case of WinRM it means it'll just hang waiting for a WinRM connection when the server isn't listening for WinRM.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, I see. Well that's annoying. I'm not sure what a good solution for that is, then. 😒
@maxlinc Looks reasonable to me, modulo that comment typo. |
Works for me. 🤘 |
Support for pre-configuring communicator transports (SSH or WinRM) via init_script setting
This adds support for an
init_script
setting. Theinit_script
is a small script that run before the Vagrant communicator connects to run Vagrant provisioners. The use ofinit_script
should be avoided whenever possible, since a normal provisioner is more portable and easier to troubleshoot when something goes wrong (since Vagrant will capture the results), but the use of aninit_script
is sometimes needed to configure the communication protocols for communication with Vagrant.Two known cases that require an
init_script
(in order to work with Rackspace base images rather than having to create custom images):The intention of
init_script
is the same for SSH & WinRM - it after the server is booted but before we tell Vagrant the machine is ready to provision. However, the implementation is slightly different for the two:It might be possible to run the init_script for SSH via cloud-init, so it would be more consistent with how
init_script
works for Windows, but that's more complicated, harder to troubleshoot, and I'm not sure cloud-init is supported on all images. So I'm not sure its worth it until there's a known use-case.