Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement host selector #2154

Closed
antonmedv opened this issue Sep 3, 2020 · 9 comments
Closed

Implement host selector #2154

antonmedv opened this issue Sep 3, 2020 · 9 comments
Labels
Milestone

Comments

@antonmedv
Copy link
Member

I'm looking for somebody to develop "host selector" feature.

Idea:

  • A host can have few labels: ['stage' => 'prod', 'role' => 'db', 'tier' => 'df.2']
  • User "selects" on which hosts to run a deploy: dep deploy 'stage=prod'
  • Or can define custom selectors in code selector('prod', 'stage=prod AND (role=db OR role=app)') dep deploy prod
  • Also default selector can be defined.
  • Selector features: label=value, and/or, brackets (...). Maybe also regexp label~=^v.+?

Code points:

@antonmedv antonmedv added this to the 7.0 milestone Sep 3, 2020
@antonmedv antonmedv changed the title Host selector Implement host selector Sep 3, 2020
@antonmedv
Copy link
Member Author

Did myself ┬─┬ノ( º _ ºノ)

@lexjwa
Copy link

lexjwa commented Oct 20, 2021

@antonmedv

It works well when there are few different application servers to deploy to. In my case I first build on the build server using

//To build on the build server

localhost('local')
    ->set('deploy_path', __DIR__ . '/.build')
    ->set('keep_releases', 10)
    ->set('stage', 'local');

I can run vendor/bin/dep build local and once build is done on the build server. It is time to deploy to 10+ application servers.

When I run vendor/bin/dep deploy all it upload the target directory to the 10+ application servers but it also build on the build server which I do not need to when deploying to application servers.

Do we have option to exclude localhost() when we use special selector all ? selector all

I tried to use stage with vendor/bin/dep deploy production all but it does not work with that as well.

host($serve_name)
              ->set('remote_user', 'forge')
              ->set('hostname', $public_ip)
              ->set('deploy_path', $deploy_path)
              ->set('stage', 'production');

@Schrank
Copy link
Contributor

Schrank commented Oct 20, 2021

No, but you can set a label on every server like this:
host()->set('label', ['servier_type' => 'app']) and then dep deploy server_type=app

@lexjwa
Copy link

lexjwa commented Oct 20, 2021

@Schrank thank you for your reply.

I added label to hosts and tried this command.

vendor/bin/dep deploy server_type=production

It gives me error
No host selected. Please, check your selector:
server_type=production

This is how I am chaining hosts.
if(count($servers) > 0){
    foreach ($servers as $s_key => $server)
    {
        $public_ip = $server->public_ip;
        $serve_name = $server->name;
        foreach ($server->instances as $i_key => $instance)
        {
            $deploy_path = $instance->deploy_path;
            host($serve_name)
                ->set('remote_user', 'forge')
                ->set('hostname', $public_ip)
                ->set('deploy_path', $deploy_path)
                ->set('stage', 'production')
                ->set('label', ['server_type' => 'production']);
        }
    }
}

To select host then I use
vendor/bin/dep deploy all server_type=production
or
vendor/bin/dep deploy server_type=production all
And the problem is still there.
1

Note:
If I run vendor/bin/dep deploy it gives me list to select hosts to deploy to (comma separated) I can use 1,2,3,4.. excluding the localhost. It works fine this way. But I want to exclude the need to select hosts like this.

@antonmedv
Copy link
Member Author

It’s labels with s. Not label.

@antonmedv
Copy link
Member Author

In process of writing docs on it.

@lexjwa
Copy link

lexjwa commented Oct 20, 2021

@antonmedv Thank you.

vendor/bin/dep deploy server_type=production works like a charm.

and thank you for putting the docs together for v7.

@CodeNinjaUG
Copy link

Was this error worked upon .. i cant seem to find a solution for the deployer
host('example.com')
->setHostname('127.0.123.23')
->setRemoteUser('root')
->set('stage','production')
->setDeployPath( '/var/www/html/yotta-api');

@Schrank
Copy link
Contributor

Schrank commented Nov 16, 2021

Hi @CodeNinjaUG, thanks for your comment! But unfortuantely I have no clue what you are talking about 🙈

  • What did you try?
  • What did you expect?
  • What happened instead?

Happy to help! Maybe it makes sense to open another issue!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants