Deployer: Deployer ignores every but last host set in YAML config

Created on 22 May 2017  路  16Comments  路  Source: deployphp/deployer

| Q | A
| ----------------- | ---
| Issue Type | Bug
| Deployer Version | 5.0.0
| Local Machine OS | Ubuntu 14.04.5 LTS, Ubuntu 16.04.2 LTS
| Remote Machine OS | Ubuntu 14.04.5 LTS

Description

If I deploy to development with settings below, it fails with Hostname or stage "development" was not found. If I deploy to production, it works. If I set up the deploy with PHP functions (set, host etc.), it works.

Steps to reproduce

Set your deployer like this:

.deploy-template: &deploy-template
    ssh_type: native
    ssh_multiplexing: true

    hostname: 10.0.0.2
    user: someuser
    port: 22
    identityFile: /root/.ssh/id_rsa


development:
    <<: *deploy-template
    stage: development
    deploy_path: /var/www/web/dev

production:
    <<: *deploy-template
    stage: production
    deploy_path: /var/www/web/www

Run: dep deploy development and dep deploy production

Content of deploy.php

<?php

namespace Deployer;


/** @noinspection PhpIncludeInspection recipe comes from Deployer tool */
require_once 'recipe/common.php';

// deploy stages settings
inventory(__DIR__ . '/config.yml');


// task
task('deploy:copy', function () {
    upload('../dist/', '{{release_path}}');
});


// deploy process
desc('Deploy your project');
task('deploy', [
    'deploy:prepare', // checks env and prepares folder for new release
    'deploy:lock',
    'deploy:release',

    'deploy:copy',

    'deploy:symlink', // swap to current release

    'deploy:unlock',
    'cleanup', // remove old releases
    'success',
]);

// automatically unlock if deploy fails
after('deploy:failed', 'deploy:unlock');

Output log

[Deployer\Exception\Exception]                  
  Hostname or stage `development` was not found.  


Exception trace:
 () at /root/.composer/vendor/deployer/deployer/src/Host/HostSelector.php:59
 Deployer\Host\HostSelector->getHosts() at /root/.composer/vendor/deployer/deployer/src/Console/TaskCommand.php:111
 Deployer\Console\TaskCommand->execute() at /root/.composer/vendor/symfony/console/Command/Command.php:262
 Symfony\Component\Console\Command\Command->run() at /root/.composer/vendor/symfony/console/Application.php:826
 Symfony\Component\Console\Application->doRunCommand() at /root/.composer/vendor/deployer/deployer/src/Console/Application.php:132
 Deployer\Console\Application->doRunCommand() at /root/.composer/vendor/symfony/console/Application.php:190
 Symfony\Component\Console\Application->doRun() at /root/.composer/vendor/symfony/console/Application.php:121
 Symfony\Component\Console\Application->run() at /root/.composer/vendor/deployer/deployer/src/Deployer.php:315
 Deployer\Deployer::run() at /root/.composer/vendor/deployer/deployer/bin/dep:111

bug

Most helpful comment

But I'm not sure 84% test coverage would ensure it doesn't break anything not under test?

I don't think what 100% coverage will guard of error as well.

All 16 comments

I just came across this. I'm glad it wasn't just me. Following.

same issue #1231

@yuvim86 It is not the same, but it is similar.

This is because L102 builds the array with the hostname being the key so the last one overwrites any previous with the same hostname.
This could be rewritten to a nested array? But I'm not sure 84% test coverage would ensure it doesn't break anything not under test?

I can take on the work if it's not going to break everything or it needs to be marked as will not fix

But I'm not sure 84% test coverage would ensure it doesn't break anything not under test?

I don't think what 100% coverage will guard of error as well.

I'll do a PR and we can go from there

@shakyj How about the PR? :-)

I have been swamped with client work. Probably this weekned

Had a few goes at it, wasn't happy with any. Working on hopefully a final one...

@shakyj Any changes?

Fixed in master, please test it someone and i'll release it)

Yeah, it works, thank you!

Yep, it works as expected, thanks.

How can I upgrade? Even this command complains about my old yml:

dep self-update

I tried to override it but it behaves the same:

curl -LO https://deployer.org/deployer.phar
mv deployer.phar /usr/local/bin/dep
chmod +x /usr/local/bin/dep
dep self-update -u

Thanks. Problem was that I had a deploy.php file in an upper folder. So, executing dep whatever would search for a deploy.php file in the upper folders. And in my case the one it found was trying to include an unexisting yml. So, mistery solved.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

sweebee picture sweebee  路  3Comments

JonasDoebertin picture JonasDoebertin  路  4Comments

antonmedv picture antonmedv  路  5Comments

jolipixel picture jolipixel  路  4Comments

khoanguyen96 picture khoanguyen96  路  5Comments