diff --git a/Asm/Ansible/Command/AbstractAnsibleCommand.php b/Asm/Ansible/Command/AbstractAnsibleCommand.php index 6dfd8ae..16359cd 100644 --- a/Asm/Ansible/Command/AbstractAnsibleCommand.php +++ b/Asm/Ansible/Command/AbstractAnsibleCommand.php @@ -160,9 +160,10 @@ protected function checkParam(string|array $param, string $glue = ' '): string * Has to return the process exit code in case of error * * @param callable|null $callback + * @param array $callback * @return int|string */ - protected function runProcess(?callable $callback): int|string + protected function runProcess(?callable $callback, array $env = []): int|string { $process = $this->processBuilder ->setArguments( @@ -174,7 +175,7 @@ protected function runProcess(?callable $callback): int|string $this->logger->debug('Executing: ' . $this->getProcessCommandline($process)); // exit code - $result = $process->run($callback); + $result = $process->run($callback, $env); // text-mode if (null === $callback) { diff --git a/Asm/Ansible/Command/AnsibleCommandInterface.php b/Asm/Ansible/Command/AnsibleCommandInterface.php index a7deda6..e602889 100644 --- a/Asm/Ansible/Command/AnsibleCommandInterface.php +++ b/Asm/Ansible/Command/AnsibleCommandInterface.php @@ -19,9 +19,10 @@ interface AnsibleCommandInterface extends LoggerAwareInterface * Returns either exit code or string output if no callback is given. * * @param callable|null $callback + * @param array $env * @return integer|string */ - public function execute(?callable $callback = null): int|string; + public function execute(?callable $callback = null, array $env = []): int|string; /** * Get parameter string which will be used to call ansible. diff --git a/Asm/Ansible/Command/AnsibleGalaxy.php b/Asm/Ansible/Command/AnsibleGalaxy.php index 9c0157d..6b36da0 100644 --- a/Asm/Ansible/Command/AnsibleGalaxy.php +++ b/Asm/Ansible/Command/AnsibleGalaxy.php @@ -17,11 +17,12 @@ final class AnsibleGalaxy extends AbstractAnsibleCommand implements AnsibleGalax * Returns either exitcode or string output if no callback is given. * * @param callable|null $callback + * @param array $env * @return integer|string */ - public function execute(?callable $callback = null): int|string + public function execute(?callable $callback = null, array $env = []): int|string { - return $this->runProcess($callback); + return $this->runProcess($callback, $env); } /** diff --git a/Asm/Ansible/Command/AnsiblePlaybook.php b/Asm/Ansible/Command/AnsiblePlaybook.php index 98dcfb4..7e59312 100644 --- a/Asm/Ansible/Command/AnsiblePlaybook.php +++ b/Asm/Ansible/Command/AnsiblePlaybook.php @@ -21,13 +21,14 @@ final class AnsiblePlaybook extends AbstractAnsibleCommand implements AnsiblePla * Returns either exit code or string output if no callback is given. * * @param callable|null $callback + * @param array $env * @return integer|string */ - public function execute(?callable $callback = null): int|string + public function execute(?callable $callback = null, array $env = []): int|string { $this->checkInventory(); - return $this->runProcess($callback); + return $this->runProcess($callback, $env); } /**