Skip to main content
Glama
tarnover
by tarnover

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

TableJSON Schema
NameRequiredDescriptionDefault
playbookYes

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>;
  • 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,
    },

Tool Definition Quality

Score is being calculated. Check back soon.

Install Server

Other Tools

Related Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/tarnover/mcp-ansible'

If you have feedback or need assistance with the MCP directory API, please join our Discord server