()
| 154 | } |
| 155 | |
| 156 | func (p *Plugin) showMainMenu() { |
| 157 | pages := p.app.Pages() |
| 158 | previousFocus := p.app.GetFocus() |
| 159 | |
| 160 | closeMenu := func() { |
| 161 | pages.RemovePage(menuPageName) |
| 162 | if previousFocus != nil { |
| 163 | p.app.SetFocus(previousFocus) |
| 164 | } |
| 165 | } |
| 166 | |
| 167 | list := tview.NewList().ShowSecondaryText(true) |
| 168 | list.SetBorder(true) |
| 169 | list.SetBorderColor(theme.Colors.Border) |
| 170 | list.SetTitle(" Ansible Toolkit ") |
| 171 | list.SetTitleColor(theme.Colors.Primary) |
| 172 | list.SetMainTextColor(theme.Colors.Primary) |
| 173 | list.SetSecondaryTextColor(theme.Colors.Secondary) |
| 174 | |
| 175 | inventory := p.currentInventory() |
| 176 | selectedNode, selectedGuest := p.currentSelectionForLimit() |
| 177 | |
| 178 | list.AddItem("Preview Inventory", "Render inventory from current nodes and guests", 0, func() { |
| 179 | p.previewInventory(inventory) |
| 180 | }) |
| 181 | list.AddItem("Save Inventory", "Write generated inventory to a file", 0, func() { |
| 182 | p.showSaveInventoryForm(inventory, p.showMainMenu) |
| 183 | }) |
| 184 | list.AddItem("Run Ping", "Run ansible ping module against this inventory", 0, func() { |
| 185 | defaultLimit := p.defaultLimitForSelection(selectedNode, selectedGuest, inventory) |
| 186 | p.showPingForm(defaultLimit, inventory, p.showMainMenu) |
| 187 | }) |
| 188 | list.AddItem("Run Ad-Hoc Task", "Run an Ansible module against this inventory", 0, func() { |
| 189 | defaultLimit := p.defaultLimitForSelection(selectedNode, selectedGuest, inventory) |
| 190 | p.showAdhocForm(defaultLimit, inventory, p.showMainMenu, &adhocFormState{ |
| 191 | Title: " Run Ad-Hoc Task ", |
| 192 | Module: "command", |
| 193 | Scope: detectScopeFromLimit(defaultLimit), |
| 194 | Limit: defaultLimit, |
| 195 | TimeoutRaw: "5m", |
| 196 | RunButtonLabel: "Run", |
| 197 | }) |
| 198 | }) |
| 199 | list.AddItem("Run Playbook", "Execute ansible-playbook on generated inventory", 0, func() { |
| 200 | defaultLimit := p.defaultLimitForSelection(selectedNode, selectedGuest, inventory) |
| 201 | p.showPlaybookForm(defaultLimit, inventory, p.showMainMenu) |
| 202 | }) |
| 203 | list.AddItem("Bootstrap Access", "Bulk-prepare hosts for Ansible access", 0, func() { |
| 204 | p.showBootstrapRunForm(inventory, p.showMainMenu) |
| 205 | }) |
| 206 | list.AddItem("SSH Setup Guide", "Show commands to prepare key-based SSH access", 0, func() { |
| 207 | p.showSetupAssistant(inventory, p.showMainMenu) |
| 208 | }) |
| 209 | list.AddItem("General Settings", "Configure inventory/run defaults", 0, func() { |
| 210 | p.showSettingsForm(p.showMainMenu) |
| 211 | }) |
| 212 | list.AddItem("Bootstrap Settings", "Configure bootstrap access defaults", 0, func() { |
| 213 | p.showBootstrapSettingsForm(p.showMainMenu) |
no test coverage detected