RunPingStream executes `ansible -m ping` and streams output lines when handler is provided.
( ctx context.Context, inventoryText, inventoryFormat, limit string, extraArgs []string, handler OutputLineHandler, )
| 82 | |
| 83 | // RunPingStream executes `ansible -m ping` and streams output lines when handler is provided. |
| 84 | func (r *Runner) RunPingStream( |
| 85 | ctx context.Context, |
| 86 | inventoryText, |
| 87 | inventoryFormat, |
| 88 | limit string, |
| 89 | extraArgs []string, |
| 90 | handler OutputLineHandler, |
| 91 | ) CommandResult { |
| 92 | inventoryPath, cleanup, err := writeTempInventory(inventoryText, inventoryFormat) |
| 93 | if err != nil { |
| 94 | return CommandResult{Err: fmt.Errorf("create temp inventory: %w", err)} |
| 95 | } |
| 96 | defer cleanup() |
| 97 | |
| 98 | args := buildAdhocArgs(inventoryPath, AdhocOptions{ |
| 99 | Pattern: "all", |
| 100 | Module: "ping", |
| 101 | Limit: limit, |
| 102 | ExtraArgs: extraArgs, |
| 103 | }) |
| 104 | return runAnsibleCommand(ctx, r.env, args, handler) |
| 105 | } |
| 106 | |
| 107 | // RunInventoryList resolves an inventory source with ansible-inventory --list. |
| 108 | func (r *Runner) RunInventoryList(ctx context.Context, inventory InventoryResult) CommandResult { |
no test coverage detected