list_tasks
View all tasks that will run when executing a specified Ansible playbook to understand the sequence of operations before deployment.
Instructions
List all tasks that would be executed by a playbook
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| playbook | Yes |
Implementation Reference
- The main handler function that runs 'ansible-playbook --list-tasks' to list tasks in the specified playbook.export async function listTasks(options: ListTasksOptions): Promise<string> { const playbookPath = validatePlaybookPath(options.playbook); // Build command with list-tasks option const command = `ansible-playbook ${playbookPath} --list-tasks`; try { // Execute command const { stdout, stderr } = await execAsync(command); return stdout || 'No tasks found in playbook'; } catch (error) { // Handle exec error const execError = error as { stderr?: string; message: string }; throw new AnsibleExecutionError( `Error listing tasks: ${execError.message}`, execError.stderr ); }
- Zod schema defining the input parameters for the list_tasks tool (requires playbook path).export const ListTasksSchema = z.object({ playbook: z.string().min(1, 'Playbook path is required'), }); export type ListTasksOptions = z.infer<typeof ListTasksSchema>;
- src/sysoperator/index.ts:70-74 (registration)Registration of the 'list_tasks' tool in the MCP server, linking schema and handler.list_tasks: { description: 'List all tasks that would be executed by a playbook', schema: ListTasksSchema, handler: playbooks.listTasks, },