( ctx context.Context, host coreansible.InventoryHost, cfg cfgpkg.AnsibleBootstrapConfig, keyContent string, dryRun bool, nodeByName map[string]coreansible.InventoryHost, guestByNodeID map[string]*api.VM, stream func(string), )
| 1289 | } |
| 1290 | |
| 1291 | func (p *Plugin) runDirectBootstrapForHost( |
| 1292 | ctx context.Context, |
| 1293 | host coreansible.InventoryHost, |
| 1294 | cfg cfgpkg.AnsibleBootstrapConfig, |
| 1295 | keyContent string, |
| 1296 | dryRun bool, |
| 1297 | nodeByName map[string]coreansible.InventoryHost, |
| 1298 | guestByNodeID map[string]*api.VM, |
| 1299 | stream func(string), |
| 1300 | ) directBootstrapResult { |
| 1301 | hostKind := strings.TrimSpace(host.Vars["pvetui_kind"]) |
| 1302 | guestType := strings.TrimSpace(host.Vars["pvetui_guest_type"]) |
| 1303 | target := strings.TrimSpace(host.Vars["ansible_host"]) |
| 1304 | user := "" |
| 1305 | switch hostKind { |
| 1306 | case hostKindNode: |
| 1307 | user = strings.TrimSpace(p.resolveNodeUser()) |
| 1308 | case hostKindGuest: |
| 1309 | user = strings.TrimSpace(p.resolveVMUser()) |
| 1310 | } |
| 1311 | password := "" |
| 1312 | keyPath := "" |
| 1313 | |
| 1314 | result := directBootstrapResult{ |
| 1315 | Alias: host.Alias, |
| 1316 | Target: target, |
| 1317 | Status: statusOK, |
| 1318 | } |
| 1319 | ansibleLogger().Debug( |
| 1320 | "direct bootstrap host start alias=%s kind=%s guest_type=%s target=%s", |
| 1321 | host.Alias, |
| 1322 | hostKind, |
| 1323 | guestType, |
| 1324 | target, |
| 1325 | ) |
| 1326 | |
| 1327 | if hostKind == hostKindNode && !strings.EqualFold(host.Vars["pvetui_online"], "true") { |
| 1328 | result.Status = statusSkipped |
| 1329 | result.Message = "node is offline" |
| 1330 | return result |
| 1331 | } |
| 1332 | if hostKind == hostKindGuest && !strings.EqualFold(host.Vars["pvetui_status"], api.VMStatusRunning) { |
| 1333 | result.Status = statusSkipped |
| 1334 | result.Message = "guest is not running" |
| 1335 | return result |
| 1336 | } |
| 1337 | if hostKind == hostKindGuest && cfg.ExcludeWindowsGuests && isWindowsGuestHost(host) { |
| 1338 | result.Status = statusSkipped |
| 1339 | result.Message = "windows guest excluded (winrm bootstrap not implemented)" |
| 1340 | return result |
| 1341 | } |
| 1342 | |
| 1343 | // Nodes only support SSH transport; require a routable IP target. |
| 1344 | if hostKind == hostKindNode { |
| 1345 | if target == "" || user == "" { |
| 1346 | result.Status = statusFailed |
| 1347 | result.Message = "missing ansible_host or SSH user" |
| 1348 | return result |
no test coverage detected