Skip to main content
Glama

run_playbook

Execute Ansible playbooks to automate infrastructure configuration and management tasks through the MCP SysOperator server.

Instructions

Run an Ansible playbook

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
playbookYes
extraVarsNo
inventoryNo
tagsNo
limitNo

Implementation Reference

  • The main handler function that runs the Ansible playbook by constructing and executing the ansible-playbook command with validation and error handling.
    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 path, optional extra vars, inventory, tags, and 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(),
    });
  • Registration of the 'run_playbook' tool in the toolDefinitions object, specifying its description, input schema, and handler function.
    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?

No annotations are provided, so the description carries the full burden of behavioral disclosure. It states 'Run an Ansible playbook', implying an execution action, but fails to disclose critical behavioral traits such as whether it requires authentication, has side effects (e.g., modifying systems), involves rate limits, or what the output looks like. This is a significant gap for a tool with potential system impacts.

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. While it may be too brief for completeness, it efficiently conveys 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 an Ansible playbook (with 5 parameters, no output schema, and no annotations), the description is incomplete. It does not cover parameter meanings, behavioral aspects like safety or output, or usage context, making it inadequate for an agent to effectively select and invoke this tool without additional information.

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%, meaning none of the 5 parameters (playbook, extraVars, inventory, tags, limit) are documented in the schema. The description adds no parameter semantics beyond the tool name, failing to explain what these parameters mean or how they affect the playbook execution, which is insufficient given the low coverage.

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 'Run an Ansible playbook' clearly states the verb ('Run') and resource ('Ansible playbook'), which is adequate. However, it lacks specificity about what 'run' entails (e.g., execution, automation) and does not distinguish this tool from sibling tools like 'run_ad_hoc', which might also involve running Ansible commands but in a different 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 does not mention sibling tools such as 'run_ad_hoc' (for ad-hoc commands) or 'check_syntax' (for validation), nor does it specify prerequisites or contexts for using this tool, leaving the agent without clear usage instructions.

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

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-sysoperator'

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