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

Method runBootstrapAccess

internal/ui/plugins/ansible/plugin.go:1097–1167  ·  view source on GitHub ↗
(
	inventory coreansible.InventoryResult,
	limit string,
	dryRun bool,
	extraArgs []string,
	timeout time.Duration,
)

Source from the content-addressed store, hash-verified

1095}
1096
1097func (p *Plugin) runBootstrapAccess(
1098 inventory coreansible.InventoryResult,
1099 limit string,
1100 dryRun bool,
1101 extraArgs []string,
1102 timeout time.Duration,
1103) {
1104 if err := p.runner.CheckAvailability(); err != nil {
1105 p.app.ShowMessageSafe(fmt.Sprintf("Ansible is not available: %v", err))
1106 return
1107 }
1108
1109 bootstrap := p.ansiblePluginConfig().Bootstrap
1110 playbookContent, err := p.buildBootstrapPlaybook(bootstrap)
1111 if err != nil {
1112 p.app.ShowMessageSafe(fmt.Sprintf("Bootstrap setup error: %v", err))
1113 return
1114 }
1115
1116 playbookPath, cleanup, err := writeTempPlaybook(playbookContent)
1117 if err != nil {
1118 p.app.ShowMessageSafe(fmt.Sprintf("Failed to create bootstrap playbook: %v", err))
1119 return
1120 }
1121
1122 appendLiveLine, closeLive := p.showLiveOutputModal("Running bootstrap access workflow...")
1123 ctx, cancel := context.WithTimeout(context.Background(), timeout)
1124 p.setRunningCancel(cancel)
1125
1126 go func() {
1127 defer cancel()
1128 defer p.clearRunningCancel()
1129 defer cleanup()
1130
1131 opts := coreansible.PlaybookOptions{
1132 PlaybookPath: playbookPath,
1133 Limit: strings.TrimSpace(limit),
1134 CheckMode: dryRun,
1135 ExtraArgs: append([]string{}, extraArgs...),
1136 }
1137
1138 if bootstrap.Parallelism > 0 {
1139 opts.ExtraArgs = append(opts.ExtraArgs, "--forks", strconv.Itoa(bootstrap.Parallelism))
1140 }
1141
1142 opts.ExtraArgs = p.mergeConfiguredAnsibleArgs(opts.ExtraArgs)
1143 p.runner.SetEnv(p.ansiblePluginConfig().Env)
1144 result := p.runner.RunPlaybookStream(
1145 ctx,
1146 inventory.Text,
1147 inventory.Format,
1148 opts,
1149 func(line string) {
1150 appendLiveLine(line)
1151 ansibleLogger().Debug("ansible bootstrap stream: %s", line)
1152 },
1153 )
1154

Callers 1

showBootstrapRunFormMethod · 0.95

Implementers 4

Plugininternal/ui/plugins/ansible/plugin.go
Plugininternal/ui/plugins/communityscripts/p
Plugininternal/ui/plugins/guestlist/plugin.g
Plugininternal/ui/plugins/commandrunner/plug

Calls 15

ansiblePluginConfigMethod · 0.95
showLiveOutputModalMethod · 0.95
setRunningCancelMethod · 0.95
clearRunningCancelMethod · 0.95
showOutputMethod · 0.95
writeTempPlaybookFunction · 0.85
ansibleLoggerFunction · 0.85
formatCommandResultFunction · 0.85
CheckAvailabilityMethod · 0.80
ShowMessageSafeMethod · 0.80

Tested by

no test coverage detected