Closed (fixed)
Project:
Drush
Component:
Base system (internal API)
Priority:
Major
Category:
Feature request
Assigned:
Issue tags:
Reporter:
Created:
7 May 2011 at 03:58 UTC
Updated:
28 Dec 2011 at 04:50 UTC
Jump to comment: Most recent file
Comments
Comment #1
greg.1.anderson commentedI'm having trouble configuring winrm, so I have not actually tested this myself yet. :P However, in simulate mode, this patch does appear to generate the correct winrs command to run a drush command remotely on a Windows server, so it just might work. To use, just add
'os' => 'windows',to the site alias for a site running Windows OS, and drush will then use winrs instead of ssh fordrush @winserver statusand the like.Note that this patch does not affect sql-sync, which remains unsupported. That issue is being tracked in #1149886: sql dump does not work with windows sql server, which I will hopefully address shortly.
Still needs a bit of documentation (ideally including winrm setup :> ).
Comment #2
kulov commentedI managed to get it working! It is ok, but needs few fixes.
Note that alias needs to have port 80 or http:// prefix added for the remote-host address otherwise winrm tries to connect to default port 5985.
Winrm prompts for password, however the prompt is not displayed on screen and you have to type it, hit Enter, wait for the command to complete and after that you get something typed on screen. It may be buffer flush issue.
Somehow the command run remotely end up escaped twice and it doesn't work unless I remove escaping in
drush_escapeshellarg($cmd, "LOCAL").There are two print statements that need to be removed:
At last - I did not define os for my alias, so $os end up empty. In
drush_osfunction it says that default os will be Linux. However call todrush_is_windows()below detects client OS as Windows. It then assumes that client and server OS are the same and make remote call to Windows OS. I am not sure that it is correct to assume remote OS to be the same as client OS. Better it would be nice to leave default OS as Linux in case one did not set os parameter in alias.Comment #3
greg.1.anderson commentedGreat!
Is there any way to provide a password to winrs non-interactively? Is there any equivalent of ssh key pairs with winrs? Having to enter a password for all remote commands is a serious liability.
I'll look into the double-escaping.
I'm not sure whether the default for an unspecified OS should be the same as the client platform or "Linux". Originally it was always "Linux"; I changed it recently. I think assuming "Linux" is probably better, because then the same alias will work the same way on different machines; it would be inelegant for an alias to change from "Linux" to "Windows" just because you sent it to someone using a different OS than you.
Comment #4
moshe weitzman commentedLooks like --password is the way. See http://ss64.com/nt/winrs.html.
I agree that docs on how to install and configure winrs would be great. I have not tried to use it yet.
Comment #5
greg.1.anderson commentedThanks, moshe.
Winrm comes pre-installed, and in theory is really easy to set up, but none of the config commands work for me -- I get 'permission denied'. I have identified that you need to run your shell as administrator, and the admin must have a non-empty password, but that is insufficient. Once I figure out how to configure it, I'll write up some docs.
Comment #6
greg.1.anderson commentedFurther work on this issue is waiting on #1058874: drush_backend_invoke buffers output till end of command. Show progress., but here are some notes on configuring winrm / winrs.
Before you use winrs, you must configure winrm. On a new install of Windows 7:
winrm quickconfigand answer "yes" to all prompts.The output I received from
winrm quickconfigis shown below:The errors do not matter; the first two operations were successful, and only the last, "grant administrative rights remotely to local users" (which does not sound like a good idea anyway) failed.
After that, you can set the TrustedHosts config variable to allow your client to connect to your server:
You can replace the "*" with the fqdn of a specific server if you do not want to open up your configuration to the whole world. (n.b. these instructions are for a dev machine setup on a local network; adequate security precautions are left as the responsibility of the reader.)
At one point, I got my Win7 box into a strange state and could not get any winrm commands to work; I would receive an "Access Denied" error regardless of what steps I tried. Running winrm quickconfig returned an error message that the system was already configured, followed by another "access denied" error. It was reported that winrm could be reset as follows:
winrm invoke restore winrm/config @{}Unfortunately, this did not work for me; I received the same "access denied" error. Perhaps this command will help in some instances, though.
Comment #7
greg.1.anderson commentedIt appears that installing msysgit is the thing that causes winrs to stop working.
Comment #8
greg.1.anderson commentedThis time, the reset instructions from #6 worked.
Comment #9
greg.1.anderson commentedThis works. Adds capability to specify 'winrs-password' to your site alias. This is documented in examples.aliases.drushrc.inc; however, cmdkey is recommended:
Comment #10
greg.1.anderson commentedFurther refactoring backend invoke to make it more reusable (e.g. from sql-sync).
Comment #11
greg.1.anderson commentedExpanding the scope of the refactoring to include sql-sync, so that remote syncs also use winrs.
Contexts now forwarded via backend invoke per #1185142: drush_invoke_process_args() does not inherit contexts
Comment #12
greg.1.anderson commentedUpping priority of Windows issues important for drush-5.0.
Comment #13
moshe weitzman commentedRead through this and I don't have much feedback. It looks fine to me. I'd like to see more doxygen for drush_sql_su() and drush_sitealias_get_db_spec().
Also, expanded test coverage would be swell. We are changing a lot of code.
Don't know that many folks are able to review this. Feel free to commit when it works for you.
Comment #14
greg.1.anderson commentedI went ahead and committed this; it works well on Linux, and all test cases pass. Remote commands on Windows work, sql-sync on Windows may need further adjustment in a future issue, but we're a lot closer.
Comment #16
moshe weitzman commentedI got wedged in the same way as Greg in #6 and the only way I could stop seeing access denied is to use the incantation at bottom of http://social.technet.microsoft.com/Forums/en-US/winserverManagement/thr....
Now my winrm looks normal (i think) but I am still seeing a hang when doing anything needing a backend call such as updatedb. An example is updatedb when it calls the sollowing (you have to actually have a pending update to see this. just update schema_version column in system table to quickly see it.)
php.exe "C:\\Users\\mweitzman\\drush\\drush.php" --php=php.exe --debug --root=C:/Users/mweitzman/temp/drupal-7.10 --uri=http://default updatedb-batch-process 4 4 --backend=2 2>&1