Deployer Can't Create Directory
| Q | A |
|---|---|
| Issue Type | Question |
| Deployer Version | 4.02 |
| Local Machine OS | Mac OS X 10.11.6 |
| Remote Machine OS | Ubuntu 16.04.1 |
Description
I've used deployer for another project but when I try to deploy a new project to a new VM I get the error:
[Symfony\Component\Process\Exception\ProcessFailedException]
The command "ssh -A -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -p
'22' 'sshuser@ipaddress' 'cd /var/www/html/project-directory && if [ ! -d shared ];
then mkdir shared; fi'" failed.
Exit Code: 255(Unknown error)
Working directory: /Users/martin/local-directory
Output:
================
Error Output:
================
but if I run the same command manually it works fine. If I delete project-directory, deployer is able to create it and releases but errors out after that.
running groups sshuser gives sshuser : deployment sudo www-data
Directory permissions are:
drwxrwxr-x 3 www-data www-data 4096 Dec 8 00:55 www
drwxrwxr-x 3 www-data www-data 4096 Dec 16 15:17 html
drwxr-xr-x 4 sshuser deployment 4096 Dec 16 17:10 project-directory
Steps to reproduce
dep deploy
I have deployer installed globally as well as on a per-project basis
Content of deploy.php
<?php
namespace Deployer;
require 'recipe/laravel.php';
$repo_url = 'private-repo';
$branch = 'master';
$server_url = 'ipaddress';
$user = 'sshuser';
$deploy_path = '/var/www/html/project-directory';
$keep_releases = 5;
// Configuration
set('http_user', 'www-data');
set('ssh_type', 'native');
set('repository', $repo_url);
set('branch', $branch);
set('keep_releases', $keep_releases);
// Laravel shared file
set('shared_files', [
'.env'
]);
// Laravel shared dirs
set('shared_dirs', [
'storage'
]);
// Laravel writable dirs
set('writable_dirs', [
'bootstrap/cache',
'storage',
'storage/app',
'storage/app/public',
'storage/framework',
'storage/framework/cache',
'storage/framework/sessions',
'storage/framework/views',
'storage/logs',
]);
// Servers
server('production', $server_url)
->user($user)
->set('deploy_path', $deploy_path);
/**
* Upload .env.production file as .env
*/
task('upload:env', function () {
upload('.env.production', '{{deploy_path}}/shared/.env');
})->desc('Environment setup');
/**
* Upload build directory and css and js files (no .map files), and rev-manifest.json
*/
task('upload:build_assets', function () {
run('mkdir {{release_path}}/public/build && mkdir {{release_path}}/public/build/css && mkdir {{release_path}}/public/build/js');
upload('public/build/rev-manifest.json', '{{release_path}}/public/build/rev-manifest.json');
foreach (glob("public/build/css/*.css") as $file) {
upload($file, '{{release_path}}/' . $file);
}
foreach (glob("public/build/js/*.js") as $file) {
upload($file, '{{release_path}}/' . $file);
}
})->desc('Upload build assets');
desc('Deploy your project');
task('deploy', [
'deploy:prepare',
'deploy:lock',
'deploy:release',
'deploy:update_code',
'upload:build_assets',
'deploy:shared',
'upload:env',
'deploy:vendors',
'deploy:writable',
'artisan:migrate',
'artisan:view:clear',
'artisan:cache:clear',
'artisan:config:cache',
'artisan:route:cache',
'artisan:optimize',
'deploy:symlink',
'deploy:unlock',
'cleanup',
]);
after('deploy', 'success');
Output log
With enabled option for verbose output -vvv.
➤ Executing task deploy:prepare
[production] > echo $0
[production] < bash
[production] > if [ ! -d /var/www/html/project-directory ]; then mkdir -p /var/www/html/project-directory; fi
[production] > if [ ! -L /var/www/html/project-directory/current ] && [ -d /var/www/html/project-directory/current ]; then echo true; fi
[production] > cd /var/www/html/project-directory && if [ ! -d .dep ]; then mkdir .dep; fi
[production] > cd /var/www/html/project-directory && if [ ! -d releases ]; then mkdir releases; fi
[production] > cd /var/www/html/project-directory && if [ ! -d shared ]; then mkdir shared; fi
➤ Executing task deploy:failed
• done on [production]
✔ Ok [0ms]
[Symfony\Component\Process\Exception\ProcessFailedException]
The command "ssh -A -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -p
'22' 'sshuser@ipaddress' 'cd /var/www/html/project-directory && if [ ! -d shared ];
then mkdir shared; fi'" failed.
Exit Code: 255(Unknown error)
Working directory: /Users/martin/local-directory
Output:
================
Error Output:
================
Exception trace:
() at /Users/martin/local-directory/vendor/symfony/process/Process.php:232
Symfony\Component\Process\Process->mustRun() at /Users/martin/local-directory/vendor/deployer/deployer/src/Server/Remote/NativeSsh.php:74
Deployer\Server\Remote\NativeSsh->run() at /Users/martin/local-directory/vendor/deployer/deployer/src/functions.php:310
Deployer\run() at /Users/martin/local-directory/vendor/deployer/deployer/recipe/deploy/prepare.php:49
Deployer\{closure}() at n/a:n/a
call_user_func() at /Users/martin/local-directory/vendor/deployer/deployer/src/Task/Task.php:91
Deployer\Task\Task->run() at /Users/martin/local-directory/vendor/deployer/deployer/src/Executor/SeriesExecutor.php:40
Deployer\Executor\SeriesExecutor->run() at /Users/martin/local-directory/vendor/deployer/deployer/src/Console/TaskCommand.php:79
Deployer\Console\TaskCommand->execute() at /Users/martin/local-directory/vendor/symfony/console/Command/Command.php:254
Symfony\Component\Console\Command\Command->run() at /Users/martin/local-directory/vendor/symfony/console/Application.php:820
Symfony\Component\Console\Application->doRunCommand() at /Users/martin/local-directory/vendor/symfony/console/Application.php:187
Symfony\Component\Console\Application->doRun() at /Users/martin/local-directory/vendor/symfony/console/Application.php:118
Symfony\Component\Console\Application->run() at /Users/martin/local-directory/vendor/deployer/deployer/src/Deployer.php:186
Deployer\Deployer->run() at /Users/martin/.composer/vendor/deployer/deployer/bin/dep:111
deploy [-p|--parallel]
I've been doing some more investigation, the deployment process seems to work when I'm using my phone as a personal hotspot, which is weird. I can ssh to the server on any wifi network, it's just the deployer part of executing commands that doesn't seem to work (not blaming deployer, I think the issue could be any one of deployer, my machine, network or production server.
Another project that uses deployer still deploys perfectly fine so the only difference then is the production server. The only thing I can think of is ports but I would've thought all that deployer needed was 22 for ssh.