/** * Constructs a AnsibleProcess object. * * @param \AnsibleWrapper\AnsibleWrapper $ansible * @param \AnsibleWrapper\AnsibleCommand $command * @param string|null $cwd */ public function __construct(AnsibleWrapper $ansible, AnsibleCommand $command, $cwd = null) { $this->ansible = $ansible; $this->command = $command; // Build the command line options, flags, and arguments. $binary = ProcessUtils::escapeArgument($ansible->getAnsibleBinary()); $commandLine = rtrim($binary . ' ' . $command->getCommandLine()); // Resolve the working directory of the Ansible process. Use the directory // in the command object if it exists. if (null === $cwd) { if (null !== ($directory = $command->getDirectory())) { if (!($cwd = realpath($directory))) { throw new AnsibleException('Path to working directory could not be resolved: ' . $directory); } } } // Finalize the environment variables, an empty array is converted // to null which enherits the environment of the PHP process. $env = $ansible->getEnvVars(); if (!$env) { $env = null; } parent::__construct($commandLine, $cwd, $env, null, $ansible->getTimeout(), $ansible->getProcOptions()); }