|
53 | 53 | get_operation_and_args, |
54 | 54 | list_dirs_above_file, |
55 | 55 | load_deploy_file, |
| 56 | + parse_cli_arg, |
56 | 57 | ) |
57 | 58 | from .virtualenv import init_virtualenv |
58 | 59 |
|
@@ -118,6 +119,11 @@ def _print_support(ctx, param, value): |
118 | 119 | multiple=True, |
119 | 120 | ) |
120 | 121 | @click.option('--fail-percent', type=int, help='% of hosts allowed to fail.') |
| 122 | +@click.option( |
| 123 | + '--data', |
| 124 | + multiple=True, |
| 125 | + help='Override data values, format key=value', |
| 126 | +) |
121 | 127 | # Auth args |
122 | 128 | @click.option( |
123 | 129 | '--sudo', is_flag=True, default=False, |
@@ -264,7 +270,7 @@ def _main( |
264 | 270 | winrm_username, winrm_password, winrm_port, |
265 | 271 | winrm_transport, shell_executable, |
266 | 272 | sudo, sudo_user, use_sudo_password, su_user, |
267 | | - parallel, fail_percent, |
| 273 | + parallel, fail_percent, data, |
268 | 274 | dry, limit, no_wait, serial, quiet, |
269 | 275 | debug, debug_data, debug_facts, debug_operations, |
270 | 276 | facts=None, print_operations=None, support=None, |
@@ -431,19 +437,36 @@ def _main( |
431 | 437 | if not quiet: |
432 | 438 | click.echo('--> Loading inventory...', err=True) |
433 | 439 |
|
| 440 | + override_data = {} |
| 441 | + |
| 442 | + for arg in data: |
| 443 | + key, value = arg.split('=', 1) |
| 444 | + override_data[key] = value |
| 445 | + |
| 446 | + override_data = { |
| 447 | + key: parse_cli_arg(value) |
| 448 | + for key, value in override_data.items() |
| 449 | + } |
| 450 | + |
| 451 | + for key, value in ( |
| 452 | + ('ssh_user', ssh_user), |
| 453 | + ('ssh_key', ssh_key), |
| 454 | + ('ssh_key_password', ssh_key_password), |
| 455 | + ('ssh_port', ssh_port), |
| 456 | + ('ssh_password', ssh_password), |
| 457 | + ('winrm_username', winrm_username), |
| 458 | + ('winrm_password', winrm_password), |
| 459 | + ('winrm_port', winrm_port), |
| 460 | + ('winrm_transport', winrm_transport), |
| 461 | + ): |
| 462 | + if value: |
| 463 | + override_data[key] = value |
| 464 | + |
434 | 465 | # Load up the inventory from the filesystem |
435 | 466 | inventory, inventory_group = make_inventory( |
436 | 467 | inventory, |
437 | 468 | deploy_dir=deploy_dir, |
438 | | - ssh_port=ssh_port, |
439 | | - ssh_user=ssh_user, |
440 | | - ssh_key=ssh_key, |
441 | | - ssh_key_password=ssh_key_password, |
442 | | - ssh_password=ssh_password, |
443 | | - winrm_username=winrm_username, |
444 | | - winrm_password=winrm_password, |
445 | | - winrm_port=winrm_port, |
446 | | - winrm_transport=winrm_transport, |
| 469 | + override_data=override_data, |
447 | 470 | ) |
448 | 471 |
|
449 | 472 | # Attach to pseudo inventory |
|
0 commit comments