New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Optionally avoid using ssh if going to localhost #98
Comments
|
James Pearson (xiong.chiamiov) posted: As also mentioned on irc, I don't normally run ssh server on a desktop machine, so I can't actually ssh to localhost. on 2009-11-11 at 03:13pm EST |
|
Travis Swicegood (tswicegood) posted: I've just implemented something similar this evening in the form of a new fabric.operations function called This is sort of a different way around this problem which works without changing the behavior of on 2010-01-11 at 12:22am EST |
|
Morgan Goose (goosemo) posted: I really don't see this being plausible. What's the point in doing run as local. One of the requirements of Fabric is sshd running on the machine, remote or loopback. The other problem being that only changing local doesn't take into account put, get, rsync_project, and others that would all still need ssh. Trying to implement those, would just really cause more issues, since it's now in the realm of making fabfiles translate to bash. on 2011-03-13 at 11:14pm EDT |
|
Jeff Forcier (bitprophet) posted: While I'm also not 100% convinced this is a great idea, it's clearly something a number of users feel the need for -- another request has been lodged as #364 with another explanation of the use case. I've also added the dry-run ticket as related to this one, because (I assume -- if any of the requesting users can verify this that'd be great) the main use case for this feature is for testing/dry-running. on 2011-06-23 at 11:26am EDT |
|
As noted in #538, if we're ever able to fully normalize the three runners so they can be used interchangeably, we'll need to make sure that shell escaping works consistently across them. Right now we don't shell escape |
|
If anyone is wondering "why would anyone do this?", the answer is that if you have a deployment pipeline, it can be helpful to run the same exact deployment script, no matter which environment, rather than having a special setup script for localhost vs. everything else. |
|
+1 for the feature |
|
+1 |
|
+10 |
|
+1 |
|
+1 To hold you over, you can just make sure you have the OpenSSH server running. First do |
|
+1 My use case is simple: I want to use the same django-deploy script to configure ec2 instances both with cloud-init through CloudWatch (the case for running local commands) and using the regular |
|
+1 This would be really useful. One use case I have is using vagrant shell provisioner to configure particular vm using fabric and without the need to ssh localhost. |
|
+1 I was surprised not to see this in Fabric already. |
|
FYI: Implementation of this feature gets more complex when you think about fabric functions like |
|
+1 Should be part of core already ! |
|
+1 It would perfectly make sense: from an abstract point of view, One more thing to point out (maybe obvious): Fabric should be smart enough to decide if a I mean: if we have and in /etc/hosts we have: then, any Taking this concept a step further, we should also treat /etc/hosts:
|
|
+1 |
|
+1 👍 |
|
👍 |
2 similar comments
|
+1 |
|
+1 |
|
Fabric 2 will use pyinvoke/invoke so this should be pretty easy to do there. I would wait for Fabric 2 for a non-hacky way to do this. |
|
👍 |
2 similar comments
|
+1 |
|
👍 |
|
Actually, this can be done using cuisine. You need to change all from cuisine import run, mode_local
mode_local()
print run("echo Hello") |
|
Great @cgarciaarano |
|
For simple use cases, this works for me: from fabric.api import run, local
# ...
# in task:
if env.host is None or env.host == 'localhost':
run = local |
|
👍 I want my fabfile to run remotely or locally when ssh isn't an option. This includes local wrappers for get/put/exists etc. |
|
👍 I have fabfiles that run both locally and remotely and I've ended up hacking my own wrapper functions for run/local/get to deal with all of subtle differences such as output capture and error handling. |
|
What if you have a ssh connection doing dynamic port forwarding and binding on 127.0.0.2 (still technically localhost) on port 2223. I can see how this could cause issues, to that end matching on localhost and resolving to 127.0.0.1 rather than also supporting the entire 127.0.0.0/8 class might be a good idea to handle. |
|
@blade2005 Yep, the whole 127...* range point to your localhost(except 127.0.0.0 and 127.255.255.255) but when you are actually pointing to your localhost you won't use port right? |
|
Honestly, this feature would probably make more sense as a 3rd party plugin built on fabric, similar to the cuisine library. Then we would just import wrapped functions for run/get/put/etc, which would know wether to run locally or remotely based on an env variable. At least this way, somebody could get this started for everybody to use. I implemented something locally, and its a lot more work than just switching between local/run. You have to consider prefixes, changed directories, sudo users, etc. |
|
Was briefly thinking about this in the context of another 2.0 related ticket, and realized that there's more that comes up besides just "
|
|
@max-arnold was trying this out in the v2 alpha and ran into confusing issues, which is to be expected at this point since - I hadn't gotten to this particular ticket's use case yet, other than ensuring At the moment, the big issue is simply the nature and API of the object bound to a task's context (
More specific thought is needed, including looking at use cases here and in linked tickets. Offhand brainstorm:
|
|
My only usecase here at the moment would be Of course one could do it like this: But why not have an option to render locally? The main use of this feature, in my case, would be to deploy application configuration to my local machine for local testing. Consider you have a This is very tiring, and it should be easier. For example, in Ansible i'd simply tell the task that it's gonna use "local connection", and it would render on the local host without trying to ssh into it. Until this feature is available in Fabric, i'll use the solution pasted above, of course, as it's just a few lines of code. It should be easier though imho. I feel like that's really the kind of stuff fabric should be making easy for me. |
|
@fninja I haven't ported from StringIO import StringIO # too lazy to remember the newer path offhand
from somewhere.jinja_wrapper import render
from invoke import task
@task
def render_settings(c):
rendered = render('settings.py.j2', {'template': 'params'})
c.put(StringIO(rendered), 'remote/path/to/settings.py')But there's probably still room for an even shorter 1-stop analogue to Either way, it raises more questions re: exactly how to treat this sort of thing - for example, Invoke-only |
|
+1 to make this a core feature |
|
Crosspost from #1637. Just an idea: Basically |
|
Another use case that I don't think I saw mentioned: Building a library of reusable functions. In my case, it's mostly It looks like this: I have no idea what happens with |
Description
run()/sudo() would intelligently see that you're going to localhost and just run local() instead. This would probably be an optional thing.
Comments from Jeff on IRC:
Originally submitted by Nick Welch (mackstann) on 2009-11-11 at 01:39pm EST
Relations
The text was updated successfully, but these errors were encountered: