( inventory coreansible.InventoryResult, limit string, dryRun bool, extraArgs []string, timeout time.Duration, )
| 1095 | } |
| 1096 | |
| 1097 | func (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 |
no test coverage detected