ansible

ansible is a cursor rule for Cursor from sanjeed5/awesome-cursor-rules-mdc. It costs 2,465 tokens per session, scanned A, original, CC0-1.0.

A set of rules for writing Ansible automation, which uses YAML instructions to configure servers and deploy software. It focuses on reusable roles, clean YAML, and reliable repeated runs.

In plain words
What is it for?
Use it when creating Ansible playbooks, roles, collections, server setup tasks, or automation checks in a delivery pipeline.
Why use it?
It helps prevent large, confusing playbooks and makes automation safer to run more than once without unwanted changes.

Cursor rule for Cursor

Written for Cursor: a Cursor rule (.mdc).

About the project

awesome-cursor-rules-mdc is a generator that creates Cursor MDC rule files from structured library information, using semantic search and language models to gather and organize guidance. Developers use it to produce reusable rules for libraries in Cursor, and the catalogue includes 200 of those rules.

sanjeed5/awesome-cursor-rules-mdc · 3,571 stars · on GitHub

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add rules/sanjeed5/awesome-cursor-rules-mdc/ansible
Clone the repo
git clone --depth 1 https://github.com/sanjeed5/awesome-cursor-rules-mdc

Made for: Cursor.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for ansible

README.md
[![agentmods](https://agentmods.dev/badge/rules/sanjeed5/awesome-cursor-rules-mdc/ansible.svg)](https://agentmods.dev/rules/sanjeed5/awesome-cursor-rules-mdc/ansible)
Your own site
<a href="https://agentmods.dev/rules/sanjeed5/awesome-cursor-rules-mdc/ansible"><img src="https://agentmods.dev/badge/rules/sanjeed5/awesome-cursor-rules-mdc/ansible.svg" alt="Measured on agentmods" height="20"></a>
Per session 2,465 This file is loaded in full into every session.
When invoked 2,465 The same file — it is already loaded in full.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.02465 $0.02465
Opus 5 $0.01233 $0.01233
Sonnet 5 $0.00493 $0.00493
Haiku 4.5 $0.00247 $0.00247

Measured 7d ago against content hash 3337d7dcf792, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-06, from the pricing page.

Security

Grade A, and why

ansible scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 7d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

rules-mdc/ansible.mdc · 293 lines

How it starts

The opening of the file, as written. The whole thing — 293 lines — stays where its author put it; the contents beside it link to each section on GitHub.

ansible Best Practices

Ansible excels when treated as infrastructure-as-code. These guidelines ensure your playbooks, roles, and modules are consistent, idempotent, and production-ready.

1. Code Organization and Structure

Always structure your Ansible content into roles and collections. Roles encapsulate specific functionalities, while collections group related roles, modules, and plugins, promoting reusability and discoverability.

  • Role Scoping: Each role or module must focus on a single, well-defined task. Avoid monolithic roles. ❌ BAD:
    # roles/webserver/tasks/main.yml
    - name: Install Nginx
      ansible.builtin.apt: name=nginx state=present
    - name: Configure Nginx
      ansible.builtin.template: src=nginx.conf.j2 dest=/etc/nginx/nginx.conf
    - name: Start Nginx
      ansible.builtin.service: name=nginx state=started
    - name: Install PHP-FPM
      ansible.builtin.apt: name=php-fpm state=present
    # ... and more
    
    ✅ GOOD:
    # roles/nginx/tasks/main.yml
    - name: Ensure Nginx is installed and configured
      ansible.builtin.include_tasks: setup.yml
    - name: Ensure Nginx service is running
      ansible.builtin.service: name=nginx state=started enabled=true
    
    # roles/php-fpm/tasks/main.yml
    - name: Ensure PHP-FPM is installed and configured
      ansible.builtin.include_tasks: setup.yml
    
  • Fact Modules: Create dedicated _info or _facts modules/tasks for gathering information, rather than overloading existing ones. ✅ GOOD:
    # roles/system_facts/tasks/main.yml
    - name: Gather custom system facts
      ansible.builtin.set_fact:
        custom_os_version: "{{ ansible_facts['distribution_major_version'] }}"
    

2. YAML Hygiene and Syntax

Enforce strict YAML formatting. Consistent syntax improves readability and prevents subtle parsing errors.

  • File Start: All YAML files must begin with ---.
  • Indentation: Use two spaces for indentation, never tabs.
  • Quotes: Quote strings only when necessary (e.g., when they contain special characters or Jinja map references). Prefer single quotes. Use double quotes for escaping characters or multi-line strings. ❌ BAD:
    - name: "Install a package"
      ansible.builtin.apt: name="my-package" state="present"
    - name: Set fact
      set_fact:
        myvar: '{{ item["key"] }}' # Incorrect quoting for Jinja map
    
    ✅ GOOD:
    ---
    - name: Install a package
      ansible.builtin.apt:
        name: my-package
        state: present
    - name: Set fact
      ansible.builtin.set_fact:
        my_var: "{{ item['key'] }}" # Double quotes for Jinja map
    - name: Print multi-line message
      ansible.builtin.debug:
        msg: |
          This is line one.
          This is line two.
    
  • Colon Spacing: Use exactly one space after a colon in key-value pairs. ❌ BAD:
    - name : start service
      service:
          name    : my_service
          state   : started
    
    ✅ GOOD:
    - name: start service
      ansible.builtin.service:
        name: my_service
        state: started
    
  • Structured Map Style: Always use the structured map style for module parameters, not the legacy key=value style. ❌ BAD:
    - name: Create directory
      ansible.builtin.file: path=/opt/app state=directory mode=0755
    
    ✅ GOOD:
    - name: Create directory
      ansible.builtin.file:
        path: /opt/app
        state: directory
        mode: '0755' # Quote octal modes
    
  • Booleans: Standardize on true/false. ❌ BAD:
    - name: Enable service
      ansible.builtin.service: name=my_service enabled=yes
      become: True
    
    ✅ GOOD:
    - name: Enable service
      ansible.builtin.service: name=my_service enabled=true
      become: true
    

Read the full file on GitHub · 293 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 7d ago First seen · 293 lines · 0 tokens per session scan A 3337d7dcf792

Subscribe to this mod's changes

ansible is a cursor rule published in the GitHub repository sanjeed5/awesome-cursor-rules-mdc (3,571 stars, last pushed 3mo ago), licensed CC0-1.0. It adds 2,465 tokens to every session, about $0.0123 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.