Bug #138
env.port not honored if host string lacks port specification
| Status: | New | Start: | 02/05/2010 | |
| Priority: | High | Due date: | ||
| Assigned to: | % Done: | 0% |
||
| Category: | Core | |||
| Target version: | 0.9.2 | |||
Description
User sm0ke in IRC says he had a problem where his remote system had a nonstandard SSH port, and his use of env.port was ignored — only specifying the port number in the host string worked.
I seem to recall this being fixed before but don’t see a ticket, so check this out — it’s quite possible it’s slipped by due to my usual emphasis on host strings over env vars.
Related issues
| related to Feature #4 | Allow for storing/using metadata about hosts | Assigned | 07/20/2009 |
History
Updated by Erich Heine 173 days ago
This is because everything in operations does this:
connections[env.host_string]
There is never any checking against env.host, env.port, and env.user. This propagates to HostConnectionCache where all opers are done based on normalize(key). This is probaly best fixed by some sort of function: get_host_from_env or something, which returns the requested stuff, prioritizing env.host et. al over env.host_string. (or whatever order of ops is desired).
Possibly even a get_connection_from_env would work…
Updated by Jeff Forcier 172 days ago
Yea, that would do it.
The more I think on it, though, the more I think this may be best solved by jumping straight to something that solves #4 — a global “use this port” only makes sense in the “connecting to one and only one server” scenario, and is often ineffective or doesn’t map well to multi-host setups.
Put another way — having per-host metadata with, perhaps, some ‘default’ specification (hello class inheritance?) would solve this problem by just making things more flexible and less confusing.
Updated by Erich Heine 172 days ago
Some initial work re my previous comment: http://github.com/sophacles/fabric/tree/bug138
Not sure what else would be needed to get everything happy.
Edit: Ok, I did that before I noticed Jeff had made his comment above. Since the work was already done, might as well keep it for reference ;)
Updated by Fábio M. Costa 76 days ago
I'm having this same problem. My server receives ssh connections on port 2222 (not the default one). Do you have any updates on this? How can i set another port to be used by fabric? Thanks
Updated by Jeff Forcier 76 days ago
Fabio, you can still specify the port in your host strings, e.g. env.hosts = ['hostname:2222'] or @hosts('hostname:2222'). See the usage docs for more info.
The only thing broken right now is that writing to env.port doesn’t work correctly, but since you can specify full host strings everywhere, it’s not usually a serious problem. (Otherwise I would've opted to fix it sooner instead of deciding to possibly wait for a more wide-ranging solution.)
Also available in: Atom