deployer icon indicating copy to clipboard operation
deployer copied to clipboard

Environment's specific config

Open adriandmitroca opened this issue 10 years ago • 9 comments

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/bin path (onlyOn method doesn't work with env())
  • disable deploy:writable task (lacks of sudo) (I would have to rewrite whole task just to specify onlyOn method)

In Capistrano I would just set this in config file for specific environment and everything would just works. What about here?

adriandmitroca avatar Apr 13 '16 10:04 adriandmitroca

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'); 

oanhnn avatar Apr 13 '16 11:04 oanhnn

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

adriandmitroca avatar Apr 13 '16 11:04 adriandmitroca

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']);

lucatrev avatar Apr 13 '16 12:04 lucatrev

@luke83

Sadly this solution doesn't work. Deployer immediately stops without any output even in debug mode.

adriandmitroca avatar Apr 14 '16 11:04 adriandmitroca

task('deploy:writable')->onlyOn(['dev', 'staging']);

This does not supported. %)

antonmedv avatar Apr 14 '16 12:04 antonmedv

@adriandmitroca @elfet it was a proposal, sorry for misunderstanding

lucatrev avatar Apr 14 '16 12:04 lucatrev

+1 I like to disallow some commands on the server too. Especially deploying on some server as they are meant for other things.

ScreamingDev avatar Sep 23 '16 12:09 ScreamingDev

Not it's possible:

task('deploy:writable')->onlyOn(['dev', 'staging']);

antonmedv avatar Jun 25 '17 04:06 antonmedv

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.

ScreamingDev avatar Jun 25 '17 12:06 ScreamingDev