mirror of
https://github.com/andres-montanez/Magallanes
synced 2024-05-26 18:32:15 +02:00
[Nostromo] Fix Symfony tasks. Tweak SSH configuration.
This commit is contained in:
parent
0bb6944c42
commit
83e66b340a
11
.mage.yml
11
.mage.yml
|
@ -1,14 +1,15 @@
|
||||||
magephp:
|
magephp:
|
||||||
# composer:
|
# composer:
|
||||||
# path: composer
|
# path: composer
|
||||||
symfony:
|
# symfony:
|
||||||
# console: bin/console
|
# console: bin/console
|
||||||
# log_dir: app/logs
|
# log_dir: app/logs
|
||||||
environments:
|
environments:
|
||||||
production:
|
production:
|
||||||
user: root
|
user: root
|
||||||
# ssh: -p 22 -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no
|
# ssh:
|
||||||
# scp: -P 22 -p -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no
|
# port: 22
|
||||||
|
# flags: -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no
|
||||||
branch: test
|
branch: test
|
||||||
host_path: /var/www/test
|
host_path: /var/www/test
|
||||||
releases: 4
|
releases: 4
|
||||||
|
@ -18,7 +19,9 @@ magephp:
|
||||||
- app/log
|
- app/log
|
||||||
- web/app_dev.php
|
- web/app_dev.php
|
||||||
hosts:
|
hosts:
|
||||||
- webserver
|
- webserver1
|
||||||
|
- webserver2
|
||||||
|
- webserver3
|
||||||
pre-deploy:
|
pre-deploy:
|
||||||
- git/update
|
- git/update
|
||||||
# - composer/install #: { flags: '--optimize' }
|
# - composer/install #: { flags: '--optimize' }
|
||||||
|
|
|
@ -378,7 +378,7 @@ class Runtime
|
||||||
{
|
{
|
||||||
$user = $this->getEnvironmentConfig('user');
|
$user = $this->getEnvironmentConfig('user');
|
||||||
$host = $this->getWorkingHost();
|
$host = $this->getWorkingHost();
|
||||||
$sshFlags = $this->getEnvironmentConfig('ssh', '-p 22 -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no');
|
$sshConfig = $this->getSSHConfig();
|
||||||
|
|
||||||
$cmdDelegate = $cmd;
|
$cmdDelegate = $cmd;
|
||||||
if ($jail) {
|
if ($jail) {
|
||||||
|
@ -391,8 +391,23 @@ class Runtime
|
||||||
}
|
}
|
||||||
|
|
||||||
$cmdRemote = str_replace(['"', '&', ';'], ['\"', '\&', '\;'], $cmdDelegate);
|
$cmdRemote = str_replace(['"', '&', ';'], ['\"', '\&', '\;'], $cmdDelegate);
|
||||||
$cmdLocal = sprintf('ssh %s %s@%s sh -c \"%s\"', $sshFlags, $user, $host, $cmdRemote);
|
$cmdLocal = sprintf('ssh -p %d %s %s@%s sh -c \"%s\"', $sshConfig['port'], $sshConfig['flags'], $user, $host, $cmdRemote);
|
||||||
|
|
||||||
return $this->runLocalCommand($cmdLocal, $timeout);
|
return $this->runLocalCommand($cmdLocal, $timeout);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getSSHConfig()
|
||||||
|
{
|
||||||
|
$sshConfig = $this->getEnvironmentConfig('ssh', ['port' => '22', 'flags' => '-q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no']);
|
||||||
|
|
||||||
|
if (!array_key_exists('port', $sshConfig)) {
|
||||||
|
$sshConfig['port'] = '22';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!array_key_exists('flags', $sshConfig)) {
|
||||||
|
$sshConfig['flags'] = '-q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no';
|
||||||
|
}
|
||||||
|
|
||||||
|
return $sshConfig;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,7 +39,7 @@ class CopyTask extends AbstractTask
|
||||||
|
|
||||||
$user = $this->runtime->getEnvironmentConfig('user');
|
$user = $this->runtime->getEnvironmentConfig('user');
|
||||||
$host = $this->runtime->getWorkingHost();
|
$host = $this->runtime->getWorkingHost();
|
||||||
$scpFlags = $this->runtime->getEnvironmentConfig('scp', '-P 22 -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no');
|
$sshConfig = $sshConfig = $this->runtime->getSSHConfig();
|
||||||
$hostPath = rtrim($this->runtime->getEnvironmentConfig('host_path'), '/');
|
$hostPath = rtrim($this->runtime->getEnvironmentConfig('host_path'), '/');
|
||||||
$currentReleaseId = $this->runtime->getReleaseId();
|
$currentReleaseId = $this->runtime->getReleaseId();
|
||||||
|
|
||||||
|
@ -48,13 +48,13 @@ class CopyTask extends AbstractTask
|
||||||
$tarGzLocal = $this->runtime->getVar('targz_local');
|
$tarGzLocal = $this->runtime->getVar('targz_local');
|
||||||
$tarGzRemote = basename($tarGzLocal);
|
$tarGzRemote = basename($tarGzLocal);
|
||||||
|
|
||||||
$cmdCopy = sprintf('scp %s %s %s@%s:%s/%s', $scpFlags, $tarGzLocal, $user, $host, $targetDir, $tarGzRemote);
|
$cmdCopy = sprintf('scp -P %d %s %s %s@%s:%s/%s', $sshConfig['port'], $sshConfig['flags'], $tarGzLocal, $user, $host, $targetDir, $tarGzRemote);
|
||||||
|
|
||||||
/** @var Process $process */
|
/** @var Process $process */
|
||||||
$process = $this->runtime->runLocalCommand($cmdCopy, 300);
|
$process = $this->runtime->runLocalCommand($cmdCopy, 300);
|
||||||
if ($process->isSuccessful()) {
|
if ($process->isSuccessful()) {
|
||||||
$cmdUntar = sprintf('cd %s && tar xfz %s', $targetDir, $tarGzRemote);
|
$cmdUnTar = sprintf('cd %s && tar xfz %s', $targetDir, $tarGzRemote);
|
||||||
$process = $this->runtime->runRemoteCommand($cmdUntar, false, 600);
|
$process = $this->runtime->runRemoteCommand($cmdUnTar, false, 600);
|
||||||
if ($process->isSuccessful()) {
|
if ($process->isSuccessful()) {
|
||||||
$cmdDelete = sprintf('rm %s/%s', $targetDir, $tarGzRemote);
|
$cmdDelete = sprintf('rm %s/%s', $targetDir, $tarGzRemote);
|
||||||
$process = $this->runtime->runRemoteCommand($cmdDelete, false);
|
$process = $this->runtime->runRemoteCommand($cmdDelete, false);
|
||||||
|
|
|
@ -45,7 +45,7 @@ class AsseticDumpTask extends AbstractTask
|
||||||
{
|
{
|
||||||
$userOptions = $this->runtime->getConfigOptions('symfony', []);
|
$userOptions = $this->runtime->getConfigOptions('symfony', []);
|
||||||
$options = array_merge(
|
$options = array_merge(
|
||||||
['path' => 'bin/console', 'env' => 'dev', 'flags' => ''],
|
['console' => 'bin/console', 'env' => 'dev', 'flags' => ''],
|
||||||
(is_array($userOptions) ? $userOptions : []),
|
(is_array($userOptions) ? $userOptions : []),
|
||||||
$this->options
|
$this->options
|
||||||
);
|
);
|
||||||
|
|
|
@ -45,7 +45,7 @@ class AssetsInstallTask extends AbstractTask
|
||||||
{
|
{
|
||||||
$userOptions = $this->runtime->getConfigOptions('symfony', []);
|
$userOptions = $this->runtime->getConfigOptions('symfony', []);
|
||||||
$options = array_merge(
|
$options = array_merge(
|
||||||
['path' => 'bin/console', 'env' => 'dev', 'target' => 'web', 'flags' => '--symlink --relative'],
|
['console' => 'bin/console', 'env' => 'dev', 'target' => 'web', 'flags' => '--symlink --relative'],
|
||||||
(is_array($userOptions) ? $userOptions : []),
|
(is_array($userOptions) ? $userOptions : []),
|
||||||
$this->options
|
$this->options
|
||||||
);
|
);
|
||||||
|
|
|
@ -45,7 +45,7 @@ class CacheClearTask extends AbstractTask
|
||||||
{
|
{
|
||||||
$userOptions = $this->runtime->getConfigOptions('symfony', []);
|
$userOptions = $this->runtime->getConfigOptions('symfony', []);
|
||||||
$options = array_merge(
|
$options = array_merge(
|
||||||
['path' => 'bin/console', 'env' => 'dev', 'flags' => ''],
|
['console' => 'bin/console', 'env' => 'dev', 'flags' => ''],
|
||||||
(is_array($userOptions) ? $userOptions : []),
|
(is_array($userOptions) ? $userOptions : []),
|
||||||
$this->options
|
$this->options
|
||||||
);
|
);
|
||||||
|
|
|
@ -45,7 +45,7 @@ class CacheWarmupTask extends AbstractTask
|
||||||
{
|
{
|
||||||
$userOptions = $this->runtime->getConfigOptions('symfony', []);
|
$userOptions = $this->runtime->getConfigOptions('symfony', []);
|
||||||
$options = array_merge(
|
$options = array_merge(
|
||||||
['path' => 'bin/console', 'env' => 'dev', 'flags' => ''],
|
['console' => 'bin/console', 'env' => 'dev', 'flags' => ''],
|
||||||
(is_array($userOptions) ? $userOptions : []),
|
(is_array($userOptions) ? $userOptions : []),
|
||||||
$this->options
|
$this->options
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in a new issue