1 | <?php |
||
27 | final class Ansible |
||
28 | { |
||
29 | |||
30 | const DEFAULT_TIMEOUT = 300; |
||
31 | |||
32 | /** |
||
33 | * @var string |
||
34 | */ |
||
35 | private $playbookCommand; |
||
36 | |||
37 | /** |
||
38 | * @var string |
||
39 | */ |
||
40 | private $galaxyCommand; |
||
41 | |||
42 | /** |
||
43 | * @var string |
||
44 | */ |
||
45 | private $ansibleBaseDir; |
||
46 | |||
47 | /** |
||
48 | * @var integer |
||
49 | */ |
||
50 | private $timeout; |
||
51 | |||
52 | /** |
||
53 | * @param string $ansibleBaseDir base directory of ansible project structure |
||
54 | * @param string $playbookCommand path to playbook executable, default ansible-playbook |
||
55 | * @param string $galaxyCommand path to galaxy executable, default ansible-galaxy |
||
56 | */ |
||
57 | public function __construct( |
||
68 | |||
69 | /** |
||
70 | * AnsiblePlaybook instance creator |
||
71 | * |
||
72 | * @return AnsiblePlaybookInterface |
||
73 | */ |
||
74 | public function playbook(): AnsiblePlaybookInterface |
||
80 | |||
81 | /** |
||
82 | * AnsibleGalaxy instance creator |
||
83 | * |
||
84 | * @return AnsibleGalaxyInterface |
||
85 | */ |
||
86 | public function galaxy(): AnsibleGalaxyInterface |
||
92 | |||
93 | /** |
||
94 | * Set process timeout in seconds. |
||
95 | * |
||
96 | * @param int $timeout |
||
97 | * @return Ansible |
||
98 | */ |
||
99 | public function setTimeout(int $timeout): Ansible |
||
105 | |||
106 | /** |
||
107 | * @param string $prefix base command |
||
108 | * @return Process |
||
109 | */ |
||
110 | private function createProcess(string $prefix): ProcessBuilder |
||
116 | |||
117 | /** |
||
118 | * @param string $command |
||
119 | * @param string $default |
||
120 | * @return string |
||
121 | * @throws CommandException |
||
122 | */ |
||
123 | private function checkCommand(string $command, string $default): string |
||
143 | |||
144 | /** |
||
145 | * @param string $dir directory to check |
||
146 | * @return string |
||
147 | * @throws CommandException |
||
148 | */ |
||
149 | private function checkDir(string $dir): string |
||
157 | } |
||
158 |