list_tasks
Preview tasks to be executed by an Ansible playbook before running it, ensuring clarity and intent alignment in automation workflows.
Instructions
List all tasks that would be executed by a playbook
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| playbook | Yes |
Input Schema (JSON Schema)
{
"$schema": "http://json-schema.org/draft-07/schema#",
"additionalProperties": false,
"properties": {
"playbook": {
"minLength": 1,
"type": "string"
}
},
"required": [
"playbook"
],
"type": "object"
}
Implementation Reference
- The handler function for the 'list_tasks' tool. It validates the playbook path, runs 'ansible-playbook --list-tasks', captures stdout, and handles errors by throwing AnsibleExecutionError.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 for list_tasks tool: requires a playbook path string.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 toolDefinitions map, linking schema and handler.list_tasks: { description: 'List all tasks that would be executed by a playbook', schema: ListTasksSchema, handler: playbooks.listTasks, },