host('ec2-52-52-234-48.us-west-1.compute.amazonaws.com')
->user('ubuntu')
->stage('staging')
->forwardAgent(true)
->multiplexing(false)
->configFile('~/.ssh/config')
->identityFile('~/.ssh/pemkey.pem')
->set('deploy_path', '/var/www/html/kolm_lite_deploy_test');
host('ec2-52-52-234-48.us-west-1.compute.amazonaws.com')
->user('ubuntu')
->stage('production')
->forwardAgent(true)
->multiplexing(false)
->configFile('~/.ssh/config')
->identityFile('~/.ssh/pemkey.pem')
->set('deploy_path', '/var/www/html/kolm_lite_deploy_test');
Im using multiple stage on same server.
When i run dep deploy staging i get run time error
Host staging not was not found.
But if i comment production host, it runs without any error.
If i place staging code at the bottom of production then it runs and vice versa for production
You can use host aliases https://deployer.org/docs/hosts#host-aliases
@yuvim86 Set it like this:
host('staging')
->hostname('ec2-52-52-234-48.us-west-1.compute.amazonaws.com')
->user('ubuntu')
->stage('staging')
->forwardAgent()
->configFile('~/.ssh/config')
->identityFile('~/.ssh/pemkey.pem')
->set('deploy_path', '/var/www/html/kolm_lite_deploy_test');
host('production')
->hostname('ec2-52-52-234-48.us-west-1.compute.amazonaws.com')
->user('ubuntu')
->stage('production')
->forwardAgent()
->configFile('~/.ssh/config')
->identityFile('~/.ssh/pemkey.pem')
->set('deploy_path', '/var/www/html/kolm_lite_deploy_test');
@antonmedv
run dep deploy staging
error:
[Error] Call to a member function stage() on array
#0 phar:///usr/local/bin/dep/src/Deployer.php(309): require()
#1 [internal function]: Deployer\Deployer::Deployer\{closure}()
#2 phar:///usr/local/bin/dep/src/Deployer.php(310): call_user_func(Object(Closure))
#3 phar:///usr/local/bin/dep/bin/dep(119): Deployer\Deployer::run('5.0.3', '/Users/never615...')
#4 /usr/local/bin/dep(4): require('phar:///usr/loc...')
#5 {main}
deploy.php
host('111.11.111.111', '222.22.222.222')
->stage('produciton')
->set("branch","master")
->user("username")
->port("666")
->set('deploy_path', '...')
->forwardAgent(true)
->multiplexing(true)
->addSshOption('UserKnownHostsFile', '/dev/null')
->addSshOption('StrictHostKeyChecking', 'no');
host('111.11.111.111', '222.22.222.222')
->stage('staging')
->set("branch","develop")
->user("username")
->port("666")
->set('deploy_path', '...')
->forwardAgent(true)
->multiplexing(true)
->addSshOption('UserKnownHostsFile', '/dev/null')
->addSshOption('StrictHostKeyChecking', 'no');
host('111.11.111.111')
->stage('test')
->set("branch","develop")
->user("username")
->port("666")
->set('deploy_path', '...')
->forwardAgent(true)
->multiplexing(true)
->addSshOption('UserKnownHostsFile', '/dev/null')
->addSshOption('StrictHostKeyChecking', 'no');
If only one stage,it's ok.
host('111.11.111.111', '222.22.222.222')
->stage('staging')
->set("branch","develop")
->user("username")
->port("666")
->set('deploy_path', '...')
->forwardAgent(true)
->multiplexing(true)
->addSshOption('UserKnownHostsFile', '/dev/null')
->addSshOption('StrictHostKeyChecking', 'no');
Stage can be only one per host.
Host aliases doesn't work work for me because i have custom directory names. So here is my solution, might help someone:
host('example.com', 'test.example.com')
->user('root')
->set('deploy_path', function () {
if (\Deployer\Task\Context::get()->getHost()->getHostname() === 'example.com') {
return '/var/www/deployments/ex.com';
} else {
return '/var/www/deployments/test.ex.com';
}
});
Edit:
The reason I did this to deploy to server (to both stages) with one command: dep deploy
In early project development days mostly I need to update both test and production stages at the same times.
host('test.example.com')
->user('root')
->set('deploy_path', '/var/www/deployments/test.ex.com');
host('example.com')
->user('root')
->set('deploy_path', '/var/www/deployments/ex.com');
Since this is a top result in Google; in 2019 you can use multiple hosts like this:
host('production')
->hostname('domain.com')
->set('deploy_path', '~/domain.com');
host('beta')
->hostname('domain.com')
->set('deploy_path', '~/beta.domain.com');
And then:
$ dep deploy production
$ dep deploy beta
Code from docs: https://deployer.org/docs/hosts.html#host-aliases
Most helpful comment
@yuvim86 Set it like this: