Environment's specific config
| Q | A |
|---|---|
| Issue Type | Question |
| Deployer Version | N/A |
| Local Machine OS | N/A |
| Remote Machine OS | N/A |
Description
I am wondering if there is possibility (like in Capistrano) to separate Deployer's config for different environments - for example on a production server I'd like to have:
- set custom
php/binpath (onlyOnmethod doesn't work withenv()) - disable
deploy:writabletask (lacks of sudo) (I would have to rewrite whole task just to specifyonlyOnmethod)
In Capistrano I would just set this in config file for specific environment and everything would just works. What about here?
set custom php/bin path (onlyOn method doesn't work with env())
Can you try?
// set special environment variable
server('svr1', 'xx.xx.xx.xx', 22)
->env('php/bin', '/usr/bin/php');
// set special environment variable, using php7
server('svr2', 'xx.xx.xx.xx', 22)
->env('php/bin', '/usr/local/php7/bin/php');
// don't set special environment variable, Deployer will use default environment variable
// Using `which php`
server('svr3', 'xx.xx.xx.xx', 22)
->env('branch', 'develop');
Thanks! It works great. But sadly problem 2 still unresolved - about handling tasks depending on environments (let's say - different deploy strategy).
I could define deploy:production and deploy:staging tasks but then:
- I would duplicate myself
- Deployment would look like
dep deploy:production production
task($name, $body) could be changed in task($name, $body = null) and return task reference when you call it without $body, so you can do:
task('deploy:writable')->onlyOn(['dev', 'staging']);
@luke83
Sadly this solution doesn't work. Deployer immediately stops without any output even in debug mode.
task('deploy:writable')->onlyOn(['dev', 'staging']);
This does not supported. %)
@adriandmitroca @elfet it was a proposal, sorry for misunderstanding
+1 I like to disallow some commands on the server too. Especially deploying on some server as they are meant for other things.
Not it's possible:
task('deploy:writable')->onlyOn(['dev', 'staging']);
Oh okay, it's about whitelisting. The issue looked like people request for blacklisting. So I voted it up. I guess I open a new one when I'm in such situation again.