RunAdhocStream executes ansible ad-hoc commands and streams output lines when handler is provided.
( ctx context.Context, inventoryText, inventoryFormat string, opts AdhocOptions, handler OutputLineHandler, )
| 181 | |
| 182 | // RunAdhocStream executes ansible ad-hoc commands and streams output lines when handler is provided. |
| 183 | func (r *Runner) RunAdhocStream( |
| 184 | ctx context.Context, |
| 185 | inventoryText, |
| 186 | inventoryFormat string, |
| 187 | opts AdhocOptions, |
| 188 | handler OutputLineHandler, |
| 189 | ) CommandResult { |
| 190 | module := strings.TrimSpace(opts.Module) |
| 191 | if module == "" { |
| 192 | return CommandResult{Err: fmt.Errorf("module is required")} |
| 193 | } |
| 194 | |
| 195 | inventoryPath, cleanup, err := writeTempInventory(inventoryText, inventoryFormat) |
| 196 | if err != nil { |
| 197 | return CommandResult{Err: fmt.Errorf("create temp inventory: %w", err)} |
| 198 | } |
| 199 | defer cleanup() |
| 200 | |
| 201 | args := buildAdhocArgs(inventoryPath, opts) |
| 202 | return runAnsibleCommand(ctx, r.env, args, handler) |
| 203 | } |
| 204 | |
| 205 | // PlaybookOptions describes ansible-playbook invocation options. |
| 206 | type PlaybookOptions struct { |
no test coverage detected