dmac / fezzik

A light deployment system that takes care of the heavy lifting.
https://rubygems.org/gems/fezzik
MIT License
37 stars 6 forks source link

More convenient way to find the current host #32

Closed bkad closed 11 years ago

bkad commented 12 years ago

This is to track the conversation we had today about making Fezzik easier to use.

There needs to be a convenient way to find out in a task the environment variables set for the current host deployed to. As far as I can tell, the only way of doing this is the following:

Fezzik.environments[target_host.split("@")[1]]

And that only works for remote tasks. So non-remote tasks (like the ones that write out the environment.rb/sh files) won't be able to reliably figure out which is the current target host.

The workaround for this seems to be making tasks that need to know about the current target host to be remote and include the above code snippet to fetch that host's environment.

cespare commented 12 years ago

There is no such thing as the "current target host" for non-remote tasks. These are only executed once, not once per target host, like remote tasks are.

Edit: That's why tasks like the one that writes out the environment files have to iterate through every target host.

Edit 2: I agree, though, that it would be nice to have one-word methods to get the current target host (for remote tasks) and the list of hosts (for regular tasks) that is guaranteed to either have or not have the user@ portion, regardless of how domain was set.

bkad commented 12 years ago

Ah, I see. I guess it felt weird writing remote tasks that don't run any remote commands. Fair enough.

A small Fezzik way to get the current environment still might be nice, I think it would make things clearer.