vendredi 20 avril 2018

Laravel - Dynamic remote.php

I'm wondering if it is possible to make the remote.php file dynamic. Let me explain in detail, I have a project where a server will be created after a certain action has been performed. I have access to the IP and other info from this server. Am I able to insert the data of this server into the connections array within remote.php and be able to connect to it doing something like?

$ssh = SSH::into($config_connection_name)->define('deploy', [
    'cd /var/www',
    'git pull origin master',
    'php artisan migrate',
]);

I'm asking this because I need to be able to connect to this newly created server and perform commands on it, I've been looking for weeks now and just can't find a solution.

My attempt would look something like this, The server will be created at the first line of code. then I'm able to fetch its IP at the 3rd line of code. But the code that tries to set the config does not work.

    $droplet = DigitalOcean::droplet()->create($storeName, 'ams3', 's-1vcpu-1gb', $images[0]->id, false, false, false, $keyArray, strval($webshop->id), true, [], [strval($webshop->id)]);

    $data = DigitalOcean::droplet()->getById($droplet->id);

    $webshopDroplet = Droplet::where("webshop_id", "=", $webshop->id)->get();

    Config::set('remote.connections.production.host', $webshopDroplet->ip);
    Config::set('remote.connections.production.username', 'root');
    Config::set('remote.connections.production.password', 'secret');

But when it does work. the remote.php file would presumably look something like this:

'connections' => [
    'production' => [
        'host'      => '',
        'username'  => '',
        'password'  => ''
    ],
    'newConnection' => [
        'host'      => '',
        'username'  => '',
        'password'  => ''
],

And then I'll be able to connect to it using this code below and perform commands on the server that was created. I have no Idea if it actually works this way but I'm running out of places to look.

$ssh = SSH::into($config_connection_name)->define('deploy', [
    'cd /var/www',
    'git pull origin master',
    'php artisan migrate',
]);

How can I make this work? Thanks in advance!



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2HhVJGw
via IFTTT

Aucun commentaire:

Enregistrer un commentaire