1 | <?php |
||
19 | final class AnsiblePlaybook extends AbstractAnsibleCommand implements AnsiblePlaybookInterface |
||
20 | { |
||
21 | /** |
||
22 | * @var boolean |
||
23 | */ |
||
24 | private $hasInventory = false; |
||
25 | |||
26 | /** |
||
27 | * Executes a command process. |
||
28 | * Returns either exitcode or string output if no callback is given. |
||
29 | * |
||
30 | * @param null $callback |
||
31 | * @return integer|string |
||
32 | */ |
||
33 | 1 | public function execute($callback = null) |
|
39 | |||
40 | /** |
||
41 | * The play to be executed. |
||
42 | * |
||
43 | * @param string $playbook |
||
44 | * @return $this |
||
45 | */ |
||
46 | 30 | public function play($playbook) |
|
52 | |||
53 | /** |
||
54 | * Ask for SSH password. |
||
55 | * |
||
56 | * @return $this |
||
57 | */ |
||
58 | 1 | public function askPass() |
|
64 | |||
65 | /** |
||
66 | * Ask for su password. |
||
67 | * |
||
68 | * @return $this |
||
69 | */ |
||
70 | 1 | public function askSuPass() |
|
76 | |||
77 | /** |
||
78 | * Ask for sudo password. |
||
79 | * |
||
80 | * @return $this |
||
81 | */ |
||
82 | 1 | public function askBecomePass() |
|
88 | |||
89 | /** |
||
90 | * Ask for vault password. |
||
91 | * |
||
92 | * @return $this |
||
93 | */ |
||
94 | 1 | public function askVaultPass() |
|
100 | |||
101 | /** |
||
102 | * Don't make any changes; instead, try to predict some of the changes that may occur. |
||
103 | * |
||
104 | * @return $this |
||
105 | */ |
||
106 | 1 | public function check() |
|
112 | |||
113 | /** |
||
114 | * Connection type to use (default=smart). |
||
115 | * |
||
116 | * @param string $connection |
||
117 | * @return $this |
||
118 | */ |
||
119 | 1 | public function connection($connection = 'smart') |
|
125 | |||
126 | /** |
||
127 | * When changing (small) files and templates, show the |
||
128 | * differences in those files; works great with --check. |
||
129 | * |
||
130 | * @return $this |
||
131 | */ |
||
132 | 1 | public function diff() |
|
138 | |||
139 | /** |
||
140 | * Set additional variables as array [ 'key' => 'value' ] or string. |
||
141 | * |
||
142 | * @param string|array $extraVars |
||
143 | * @return $this |
||
144 | */ |
||
145 | 1 | public function extraVars($extraVars = '') |
|
152 | |||
153 | /** |
||
154 | * Run handlers even if a task fails. |
||
155 | * |
||
156 | * @return $this |
||
157 | */ |
||
158 | 1 | public function forceHandlers() |
|
164 | |||
165 | /** |
||
166 | * Specify number of parallel processes to use (default=5). |
||
167 | * |
||
168 | * @param int $forks |
||
169 | * @return $this |
||
170 | */ |
||
171 | 1 | public function forks($forks = 5) |
|
177 | |||
178 | /** |
||
179 | * Show help message and exit. |
||
180 | * |
||
181 | * @return $this |
||
182 | */ |
||
183 | 1 | public function help() |
|
189 | |||
190 | /** |
||
191 | * Specify inventory host file (default=/etc/ansible/hosts). |
||
192 | * |
||
193 | * @param string $inventory filename for hosts file |
||
194 | * @return $this |
||
195 | */ |
||
196 | 1 | public function inventoryFile($inventory = '/etc/ansible/hosts') |
|
203 | |||
204 | /** |
||
205 | * Further limit selected hosts to an additional pattern. |
||
206 | * |
||
207 | * @param array|string $subset list of hosts |
||
208 | * @return $this |
||
209 | */ |
||
210 | 2 | public function limit($subset = '') |
|
218 | |||
219 | /** |
||
220 | * Outputs a list of matching hosts; does not execute anything else. |
||
221 | * |
||
222 | * @return $this |
||
223 | */ |
||
224 | 1 | public function listHosts() |
|
230 | |||
231 | /** |
||
232 | * List all tasks that would be executed. |
||
233 | * |
||
234 | * @return $this |
||
235 | */ |
||
236 | 1 | public function listTasks() |
|
242 | |||
243 | /** |
||
244 | * Specify path(s) to module library (default=/usr/share/ansible/). |
||
245 | * |
||
246 | * @param array $path list of paths for modules |
||
247 | * @return $this |
||
248 | */ |
||
249 | 1 | public function modulePath($path = ['/usr/share/ansible/']) |
|
255 | |||
256 | /** |
||
257 | * Disable cowsay |
||
258 | * |
||
259 | * @codeCoverageIgnore |
||
260 | * @return $this |
||
261 | */ |
||
262 | public function noCows() |
||
268 | |||
269 | /** |
||
270 | * Use this file to authenticate the connection. |
||
271 | * |
||
272 | * @param string $file private key file |
||
273 | * @return $this |
||
274 | */ |
||
275 | 1 | public function privateKey($file) |
|
281 | |||
282 | /** |
||
283 | * Only run plays and tasks whose tags do not match these values. |
||
284 | * |
||
285 | * @param array|string $tags list of tags to skip |
||
286 | * @return $this |
||
287 | */ |
||
288 | 1 | public function skipTags($tags = '') |
|
296 | |||
297 | /** |
||
298 | * Start the playbook at the task matching this name. |
||
299 | * |
||
300 | * @param string $task name of task |
||
301 | * @return $this |
||
302 | */ |
||
303 | 1 | public function startAtTask($task) |
|
309 | |||
310 | /** |
||
311 | * One-step-at-a-time: confirm each task before running. |
||
312 | * |
||
313 | * @return $this |
||
314 | */ |
||
315 | 1 | public function step() |
|
321 | |||
322 | /** |
||
323 | * Run operations with su. |
||
324 | * |
||
325 | * @return $this |
||
326 | */ |
||
327 | 1 | public function su() |
|
333 | |||
334 | /** |
||
335 | * Run operations with su as this user (default=root). |
||
336 | * |
||
337 | * @param string $user |
||
338 | * @return $this |
||
339 | */ |
||
340 | 1 | public function suUser($user = 'root') |
|
346 | |||
347 | /** |
||
348 | * Enable privilege escalation |
||
349 | * |
||
350 | * @return $this |
||
351 | * @see http://docs.ansible.com/ansible/become.html |
||
352 | */ |
||
353 | 1 | public function become() |
|
359 | |||
360 | /** |
||
361 | * Desired sudo user (default=root). |
||
362 | * |
||
363 | * @param string $user |
||
364 | * @return $this |
||
365 | */ |
||
366 | 1 | public function becomeUser($user = 'root') |
|
372 | |||
373 | /** |
||
374 | * Perform a syntax check on the playbook, but do not execute it. |
||
375 | * |
||
376 | * @return $this |
||
377 | */ |
||
378 | 1 | public function syntaxCheck() |
|
384 | |||
385 | /** |
||
386 | * Only run plays and tasks tagged with these values. |
||
387 | * |
||
388 | * @param string|array $tags list of tags |
||
389 | * @return $this |
||
390 | */ |
||
391 | 1 | public function tags($tags) |
|
399 | |||
400 | /** |
||
401 | * Override the SSH timeout in seconds (default=10). |
||
402 | * |
||
403 | * @param int $timeout |
||
404 | * @return $this |
||
405 | */ |
||
406 | 1 | public function timeout($timeout = 10) |
|
412 | |||
413 | /** |
||
414 | * Connect as this user. |
||
415 | * |
||
416 | * @param string $user |
||
417 | * @return $this |
||
418 | */ |
||
419 | 2 | public function user($user) |
|
425 | |||
426 | /** |
||
427 | * Vault password file. |
||
428 | * |
||
429 | * @param string $file |
||
430 | * @return $this |
||
431 | */ |
||
432 | 1 | public function vaultPasswordFile($file) |
|
438 | |||
439 | /** |
||
440 | * Verbose mode (vvv for more, vvvv to enable connection debugging). |
||
441 | * |
||
442 | * @param string $verbose |
||
443 | * @return $this |
||
444 | */ |
||
445 | 1 | public function verbose($verbose = 'v') |
|
451 | |||
452 | /** |
||
453 | * Get parameter string which will be used to call ansible. |
||
454 | * |
||
455 | * @param bool $asArray |
||
456 | * @return string|array |
||
457 | */ |
||
458 | 30 | public function getCommandlineArguments($asArray = true) |
|
464 | |||
465 | /** |
||
466 | * Show program's version number and exit. |
||
467 | * |
||
468 | * @return $this |
||
469 | */ |
||
470 | 1 | public function version() |
|
476 | |||
477 | /** |
||
478 | * If no inventory file is given, assume |
||
479 | */ |
||
480 | 31 | private function checkInventory() |
|
487 | } |
||
488 |