MCPcopy Create free account
hub / github.com/devnullvoid/pvetui / RunAdhocStream

Method RunAdhocStream

internal/plugins/ansible/runner.go:183–203  ·  view source on GitHub ↗

RunAdhocStream executes ansible ad-hoc commands and streams output lines when handler is provided.

(
	ctx context.Context,
	inventoryText,
	inventoryFormat string,
	opts AdhocOptions,
	handler OutputLineHandler,
)

Source from the content-addressed store, hash-verified

181
182// RunAdhocStream executes ansible ad-hoc commands and streams output lines when handler is provided.
183func (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.
206type PlaybookOptions struct {

Callers 1

RunAdhocMethod · 0.95

Calls 3

writeTempInventoryFunction · 0.85
buildAdhocArgsFunction · 0.85
runAnsibleCommandFunction · 0.85

Tested by

no test coverage detected