Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions Asm/Ansible/Command/AbstractAnsibleCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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) {
Expand Down
3 changes: 2 additions & 1 deletion Asm/Ansible/Command/AnsibleCommandInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
5 changes: 3 additions & 2 deletions Asm/Ansible/Command/AnsibleGalaxy.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

/**
Expand Down
5 changes: 3 additions & 2 deletions Asm/Ansible/Command/AnsiblePlaybook.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

/**
Expand Down