Skip to main content
Glama
tarnover
by tarnover

run_playbook

Execute and manage Ansible playbooks directly through the MCP server, enabling automation of tasks, inventory management, and configuration deployment with specified parameters.

Instructions

Run an Ansible playbook

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
extraVarsNo
inventoryNo
limitNo
playbookYes
tagsNo

Implementation Reference

  • The handler function that runs an Ansible playbook by constructing and executing the ansible-playbook command with provided options like inventory, extra vars, tags, and limit.
    export async function runPlaybook(options: RunPlaybookOptions): Promise<string> {
      const playbookPath = validatePlaybookPath(options.playbook);
      const inventoryPath = validateInventoryPath(options.inventory);
      
      // Build command
      let command = `ansible-playbook ${playbookPath}`;
      
      // Add inventory if specified
      if (inventoryPath) {
        command += ` -i ${inventoryPath}`;
      }
      
      // Add extra vars if specified
      if (options.extraVars && Object.keys(options.extraVars).length > 0) {
        const extraVarsJson = JSON.stringify(options.extraVars);
        command += ` --extra-vars '${extraVarsJson}'`;
      }
      
      // Add tags if specified
      if (options.tags) {
        command += ` --tags "${options.tags}"`;
      }
      
      // Add limit if specified
      if (options.limit) {
        command += ` --limit "${options.limit}"`;
      }
    
      try {
        // Execute command
        const { stdout, stderr } = await execAsync(command);
        return stdout || 'Playbook executed successfully (no output)';
      } catch (error) {
        // Handle exec error
        const execError = error as { stderr?: string; message: string };
        throw new AnsibleExecutionError(
          `Error running playbook: ${execError.message}`,
          execError.stderr
        );
      }
  • Zod schema defining the input parameters for the run_playbook tool: playbook (required), extraVars, inventory, tags, limit.
    export const RunPlaybookSchema = z.object({
      playbook: z.string().min(1, 'Playbook path is required'),
      extraVars: z.record(z.any()).optional(),
      inventory: z.string().optional(),
      tags: z.string().optional(),
      limit: z.string().optional(),
    });
    
    export type RunPlaybookOptions = z.infer<typeof RunPlaybookSchema>;
  • Registration of the run_playbook tool in the toolDefinitions map, linking schema and handler.
    run_playbook: {
      description: 'Run an Ansible playbook',
      schema: RunPlaybookSchema,
      handler: playbooks.runPlaybook,
    },
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It only states the action without detailing execution behavior, such as whether it's synchronous/asynchronous, error handling, or output format. This is inadequate for a tool that likely performs complex operations.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is extremely concise with a single sentence, 'Run an Ansible playbook', which is front-loaded and wastes no words. It efficiently communicates the core purpose without unnecessary elaboration.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the complexity of running Ansible playbooks, 5 parameters with 0% schema coverage, no annotations, and no output schema, the description is incomplete. It lacks details on execution behavior, parameter usage, and expected outcomes, making it insufficient for effective tool use.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters2/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0%, so the description must compensate by explaining parameters. It adds no meaning beyond the schema, failing to clarify what parameters like 'extraVars', 'inventory', or 'limit' do or how they affect playbook execution, leaving significant gaps.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose3/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description states the tool's purpose as 'Run an Ansible playbook', which clearly indicates the action (run) and resource (Ansible playbook). However, it doesn't distinguish this tool from its sibling 'run_ad_hoc', which also performs Ansible operations, making the purpose somewhat vague in context.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention sibling tools like 'run_ad_hoc' or 'check_syntax', nor does it specify contexts or prerequisites for running playbooks, leaving usage unclear.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

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