mattbrictson / tomo

A friendly CLI for deploying Rails apps ✨

Home Page:https://tomo.mattbrictson.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Overrriding host by cli option

jkprg opened this issue · comments

commented

I often deploy rails app to ad-hoc servers. It would be handy to be able to (re)define host via cli option (including optional role).

Other than that tomo is buttery smooth for rails 6 apps so far :-). Thx a lot

@jkprg I'm glad tomo is working smoothly for you!

My gut feeling is that overriding the host is not a very common use case, so I am hesitant to add this to the CLI. Not to say it won't get added to tomo at some point, but for now I'd like to keep the CLI pretty tight.

However since .tomo/config.rb is a ruby file, I think there is a pretty elegant way to add this with an environment variable. Have you tried something like this?

# .tomo/config.rb
host ENV.fetch("TOMO_HOST, "deployer@my.default.host.com")

Now tomo deploy will deploy to deployer@my.default.host.com by default, but you can override it at the command line like this:

$ TOMO_HOST=user@different.host.com tomo deploy

Will that work?

Oh I missed the part where you also mentioned you like to specify the role. Hmm. I suppose you could use an env var for that too, although now it is starting to look a bit messy:

# .tomo/config.rb
host ENV.fetch("TOMO_HOST, "deployer@my.default.host.com"),
     roles: ENV.fetch("TOMO_ROLES", "app,worker").split(",")
$ TOMO_HOST=user@different.host.com TOMO_ROLES="worker" tomo deploy
commented

Thx for you comment. Yes, ENV is the way I'm using now. I don't know how common this use-case is. I use ad-hoc deployment in case I don't want to make an installation package (various reasons). Ok. I agree to wait if anybody else will request this feature too.

Cool, I will close this issue for now. If the situation changes and we get more comments on this feature I'll reopen it.