Skip to content
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

configuring hosts in v2 #1748

Closed
peteruhnak opened this issue May 14, 2018 · 4 comments
Closed

configuring hosts in v2 #1748

peteruhnak opened this issue May 14, 2018 · 4 comments

Comments

@peteruhnak
Copy link

Hi! Is it possible to specify hosts either in a config file or the fabfile itself?

I know I can provide them via CLI (-H), but if the fabfile is designed to communicate with a specific server, then it just forces the user to do extra stuff for no good reason.

The "best" solution I could figure out was to create the connection by hand, e.g.

@task
def my_ls(c):
    conn = Connection('myhost')
    conn.run('ls')

but that seems quite dirty as I need to (1) duplicate it everywhere and (2) it makes the context argument pointless.

@timonweb
Copy link

timonweb commented May 14, 2018

I have the same question. I came up with a solution of putting conn = Connection('myhost') at the beginning of the fabfile so it looks like this:

conn = Connection('myhost')

@task
def my_ls(c):
    conn.run('ls')

@task
def my_cd(c):
    conn.run('cd')

....

But I don't like the solution and feel that there should be a way to inject a default connection into the context.

@mjmare
Copy link

mjmare commented May 16, 2018

I'd like to know as well. Would be convenient to be able to put hosts in the config file.

Also not providing a host list (with -H) defaults to localhost. I'd like to see an option to prevent this/raise error.

@grantjenks
Copy link

Agreed with all above. I really miss the old env.hosts setting. It was beautifully simple.

-1 on needing another config file like invoke.yaml or whatnot. I would much prefer to monkey-patch or some kind of import hook that let me state the hosts.

It also took me a while to figure out that ctx.local is not present if no hosts are specified :(

@bitprophet
Copy link
Member

See #4!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants