- Create AnsibleDeployStage using framework's Process module for secure command execution - Integrate AnsibleDeployStage into DeploymentPipelineCommands for production deployments - Add force_deploy flag support in Ansible playbook to override stale locks - Use PHP deployment module as orchestrator (php console.php deploy:production) - Fix ErrorAggregationInitializer to use Environment class instead of $_ENV superglobal Architecture: - BuildStage → AnsibleDeployStage → HealthCheckStage for production - Process module provides timeout, error handling, and output capture - Ansible playbook supports rollback via rollback-git-based.yml - Zero-downtime deployments with health checks
43 lines
1.5 KiB
PHP
43 lines
1.5 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Framework\Deployment\Pipeline;
|
|
|
|
use App\Framework\Config\Environment;
|
|
use App\Framework\DI\Container;
|
|
use App\Framework\DI\Initializer;
|
|
use App\Framework\Deployment\Pipeline\Stages\AnsibleDeployStage;
|
|
use App\Framework\Filesystem\ValueObjects\FilePath;
|
|
use App\Framework\Logging\Logger;
|
|
use App\Framework\Process\Process;
|
|
|
|
/**
|
|
* Deployment Pipeline Initializer
|
|
*
|
|
* Registers deployment pipeline components with the DI container.
|
|
*/
|
|
final readonly class DeploymentPipelineInitializer
|
|
{
|
|
#[Initializer]
|
|
public function initialize(Container $container): void
|
|
{
|
|
// Register AnsibleDeployStage
|
|
$container->bind(AnsibleDeployStage::class, function (Container $container) {
|
|
$env = $container->get(Environment::class);
|
|
|
|
// Get paths from environment or use defaults
|
|
$projectRoot = $env->get('PROJECT_ROOT', '/home/michael/dev/michaelschiemer');
|
|
$inventoryPath = FilePath::fromString($projectRoot . '/deployment/infrastructure/inventories');
|
|
$playbookPath = FilePath::fromString($projectRoot . '/deployment/infrastructure/playbooks/deploy-rsync-based.yml');
|
|
|
|
return new AnsibleDeployStage(
|
|
process: $container->get(Process::class),
|
|
logger: $container->get(Logger::class),
|
|
ansibleInventoryPath: $inventoryPath,
|
|
ansiblePlaybookPath: $playbookPath
|
|
);
|
|
});
|
|
}
|
|
}
|