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

Method RunPlaybookStream

internal/plugins/ansible/runner.go:219–239  ·  view source on GitHub ↗

RunPlaybookStream executes ansible-playbook and streams output lines when handler is provided.

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

Source from the content-addressed store, hash-verified

217
218// RunPlaybookStream executes ansible-playbook and streams output lines when handler is provided.
219func (r *Runner) RunPlaybookStream(
220 ctx context.Context,
221 inventoryText,
222 inventoryFormat string,
223 opts PlaybookOptions,
224 handler OutputLineHandler,
225) CommandResult {
226 playbookPath := strings.TrimSpace(opts.PlaybookPath)
227 if playbookPath == "" {
228 return CommandResult{Err: fmt.Errorf("playbook path is required")}
229 }
230
231 inventoryPath, cleanup, err := writeTempInventory(inventoryText, inventoryFormat)
232 if err != nil {
233 return CommandResult{Err: fmt.Errorf("create temp inventory: %w", err)}
234 }
235 defer cleanup()
236
237 args := buildPlaybookArgs(inventoryPath, playbookPath, opts)
238 return runAnsiblePlaybookCommand(ctx, r.env, args, handler)
239}
240
241func buildAdhocArgs(inventoryPath string, opts AdhocOptions) []string {
242 pattern := strings.TrimSpace(opts.Pattern)

Callers 2

RunPlaybookMethod · 0.95
runBootstrapAccessMethod · 0.80

Calls 3

writeTempInventoryFunction · 0.85
buildPlaybookArgsFunction · 0.85

Tested by

no test coverage detected