argument('name'); $host = $this->argument('host'); $id = $this->argument('id'); $namespace = 'hosting-deploy'; $kubeDir = storage_path("app/kube/{$name}"); File::ensureDirectoryExists($kubeDir); // 1. Generate K8s YAMLs File::put("{$kubeDir}/deployment.yaml", $this->deployment($name, $id, $namespace)); File::put("{$kubeDir}/service.yaml", $this->service($name, $id, $namespace)); File::put("{$kubeDir}/ingress.yaml", $this->ingress($name, $host, $id, $namespace)); $this->info("✅ K8s manifests generated."); // 2. Run Ansible to copy files and apply kube $ansiblePlaybook = base_path("ansible/deploy_site.yml"); $process = new Process( [ 'ansible-playbook', $ansiblePlaybook, '-i', base_path('ansible/inventory/hosts.ini'), '--extra-vars', "sitename={$name}", '--extra-vars', "siteid={$id}" ], null, // cwd ); $process->setTimeout(300); $process->run(function ($type, $buffer) { echo $buffer; }); if ($process->isSuccessful()) { $this->info("🚀 Site '{$name}' deployed successfully."); } else { $this->error("❌ Ansible deployment failed."); } } private function deployment(string $name, string $id, string $namespace): string { return <<