Deployer: You need to specify at least one host or stage. use inventory('hosts.yml');

Created on 25 Oct 2017  路  2Comments  路  Source: deployphp/deployer

| Q | A
| ----------------- | ---
| Issue Type | Bug, Question
| Deployer Version | 6.0.3
| Local Machine OS | 7.1.5
| Remote Machine OS | CentOS 7.0

Description

  • use inventory('hosts.yml');
  • You need to specify at least one host or stage.

Steps to reproduce

  • dep build

Content of hosts.yml

domain.com.a:
  hostname: 192.168.15.91
  user: name
  port: 22
  configFile: ~/.ssh/config
  identityFile: ~/.ssh/id_rsa
  forwardAgent: true
  multiplexing: true
  sshOptions:
    UserKnownHostsFile: /dev/null
    StrictHostKeyChecking: no
  stage: production
  roles:
    - app
    - db
  deploy_path: ~/app
  extra_param: "foo {{hostname}}"

domain.com.b:
  hostname: 192.168.15.92
  user: name
  port: 22
  configFile: ~/.ssh/config
  identityFile: ~/.ssh/id_rsa
  forwardAgent: true
  multiplexing: true
  sshOptions:
    UserKnownHostsFile: /dev/null
    StrictHostKeyChecking: no
  stage: production
  roles:
    - app
    - db
  deploy_path: ~/app
  extra_param: "foo {{hostname}}"

Content of deploy.php

<?php
namespace Deployer;

require 'recipe/common.php';
require 'recipe/rsync.php';

// Project name
set('application', 'testPull');

// Project repository
set('repository', '[email protected]:_inc/xxx.git');

// [Optional] Allocate tty for git clone. Default value is false.
set('git_tty', false);

// Shared files/dirs between deploys 
set('shared_files', []);
set('shared_dirs', []);

// Writable dirs by web server 
set('writable_dirs', []);
set('allow_anonymous_stats', false);

set('branch', 'master');

set('release_name', function(){
    return date('YmdHis');
});

// Hosts
inventory('hosts.yml');

// Tasks

task('build',function(){
    set('deploy_path', '/root/{{application}}');
    invoke('deploy:info');
    invoke('deploy:prepare');
    invoke('deploy:lock');
    invoke('deploy:release');
    invoke('deploy:update_code');
    invoke('deploy:shared');
    invoke('deploy:writable');
    invoke('deploy:clear_paths');
    invoke('deploy:symlink');
    invoke('deploy:unlock');
    invoke('cleanup');
    invoke('success');
})->local()->desc('build local project');

// [Optional] If deploy fails automatically unlock.
after('deploy:failed', 'deploy:unlock');

Output log

Exception trace:
() at phar:///usr/local/bin/dep/src/Host/HostSelector.php:75
Deployer\Host\HostSelector->getHosts() at phar:///usr/local/bin/dep/src/Console/TaskCommand.php:118
Deployer\Console\TaskCommand->execute() at phar:///usr/local/bin/dep/vendor/symfony/console/Command/Command.php:264
Symfony\Component\Console\Command\Command->run() at phar:///usr/local/bin/dep/vendor/symfony/console/Application.php:869
Symfony\Component\Console\Application->doRunCommand() at phar:///usr/local/bin/dep/src/Console/Application.php:132
Deployer\Console\Application->doRunCommand() at phar:///usr/local/bin/dep/vendor/symfony/console/Application.php:223
Symfony\Component\Console\Application->doRun() at phar:///usr/local/bin/dep/vendor/symfony/console/Application.php:130
Symfony\Component\Console\Application->run() at phar:///usr/local/bin/dep/src/Deployer.php:324
Deployer\Deployer::run() at phar:///usr/local/bin/dep/bin/dep:119
require() at /usr/local/bin/dep:4

Most helpful comment

dep deploy production

Or add to your _deploy.php_:

set('default_stage', 'production');

All 2 comments

dep deploy production

Or add to your _deploy.php_:

set('default_stage', 'production');

This issue should be closed.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ovaiskhan11 picture ovaiskhan11  路  4Comments

dima-stefantsov picture dima-stefantsov  路  4Comments

exts picture exts  路  3Comments

k-solnushkin picture k-solnushkin  路  5Comments

brunodevel picture brunodevel  路  3Comments