Docsible is a command-line interface (CLI) written in Python that automates the documentation of Ansible roles and collections. It generates a Markdown-formatted README file for role or collection by scanning the Ansible YAML files.
- Generates a README in Markdown format
- Scans and includes default variables and role-specific variables
- Parses tasks, including special Ansible task types like 'block' and 'rescue'
- Optionally includes playbook content in the README
- CLI-based, easy to integrate into a CI/CD pipeline
- Provides a templating feature to customize output
- Supports multiple YAML files within
tasks,defaults,varsdirectory - Includes meta-data like author and license from
meta/main.[yml/yaml] - Generates a well-structured table for default and role-specific variables
- Support for encrypted Ansible Vault variables
- NEW: Flexible project structure support (AWX, monorepos, custom directories)
- NEW: Auto-detection of various Ansible project layouts
- NEW: Optional
.docsible.ymlconfiguration for custom structures - NEW: Comment tag flexibility (supports both
-and_separators) - NEW: Intelligent caching system (4-100x faster on repeated runs)
- NEW: Modular codebase with improved maintainability
How to create virtual env with python3
python3 -m venv docsible
source docsible/bin/activateTo install Docsible, you can run:
pip install docsibleTo use Docsible, you can run the following command in your terminal:
docsible role --role /path/to/ansible/role --playbook /path/to/playbook.yml --graphdocsible role --collection ./collections_tests/lucian/ --no-backup --graphdocsible role --role /path/to/ansible/role # without include a playbook into readmeDocsible now supports flexible project structures including AWX projects, monorepos, and custom directory layouts!
# Create a .docsible.yml configuration file in your project
docsible init
# Or specify a custom path
docsible init --path /path/to/your/project# For a monorepo with roles in ansible/roles/
docsible role --collection /path/to/monorepoIf your project uses custom directory names, create a .docsible.yml:
structure:
defaults_dir: 'role_defaults'
vars_dir: 'variables'
tasks_dir: 'playbooks'Then run docsible normally:
docsible role --role /path/to/custom/roleFor detailed configuration options, see CONFIGURATION.md
Use the --hybrid flag to generate a README with a mix of manual sections (for high-level docs) and auto-generated sections (for technical details):
# Generate README with hybrid template
docsible role --role ./my-role --hybrid --graph --comments
# Auto-generates technical sections while preserving manual content areas
# Perfect for maintaining both overview docs and accurate technical detailsThe hybrid template includes:
- Manual sections: Quick Start, Architecture Overview, Example Playbooks, Testing, Compatibility, etc.
- Auto-generated sections: Task Execution Flow, Role Variables, Task Details, Dependencies, Role Metadata
- Clear HTML comments (
<!-- MANUALLY MAINTAINED -->vs<!-- DOCSIBLE GENERATED -->) showing which sections to customize
This approach lets you maintain high-level narrative documentation while ensuring technical details stay accurate and up-to-date!
$ docsible role --help
π Input Paths:
-r, --role TEXT Path to the Ansible role directory.
-c, --collection TEXT Path to the Ansible collection directory.
-p, --playbook TEXT Path to the playbook file.
πΎ Output Control:
-o, --output TEXT Output readme file name.
-nob, --no-backup Do not backup the readme before remove.
-a, --append Append to the existing README.md instead of replacing.
--dry-run Preview what would be generated without writing any files.
--validate/--no-validate Validate markdown formatting before writing.
--auto-fix Automatically fix common markdown formatting issues.
--strict-validation Fail generation if markdown validation errors are found.
π Content Sections:
--no-vars Hide variable documentation
--no-tasks Hide task lists and task details
--no-diagrams Hide all Mermaid diagrams
--no-examples Hide example playbook sections
--no-metadata Hide role metadata, author, and license
--no-handlers Hide handlers section
--include-complexity Include complexity analysis section in README
--minimal Generate minimal documentation (enables all --no-* flags)
π¨ Templates:
--md-role-template Path to the role markdown template file
--md-collection-template Path to the collection markdown template file
--hybrid Use hybrid template (manual + auto-generated sections)
π Visualization:
-g, --graph Generate Mermaid diagrams for role visualization
-com, --comments Extract and include inline comments from task files
-tl, --task-line Include source file line numbers for each task
--simplify-diagrams Show only high-level diagrams, hide detailed flowcharts
π Analysis & Complexity:
--complexity-report Include role complexity analysis in documentation
--simplification-report Include detailed pattern analysis with simplification suggestions
--show-dependencies Generate task dependency matrix table
--analyze-only Analyze role complexity without generating documentation
π Repository Integration:
-ru, --repository-url TEXT Repository base URL (used for standalone roles)
-rt, --repo-type TEXT Repository type: github, gitlab, gitea, etc.
-rb, --repo-branch TEXT Repository branch name (e.g., main or master)π Input Paths:
--role, -r: Path to Ansible role directory
--collection, -c: Path to Ansible collection directory
--playbook, -p: Path to playbook file
πΎ Output Control:
--output, -o: Output filename (default: README.md)
--no-backup, -nob: Don't create backup before overwriting
--append, -a: Append to existing README instead of replacing
--no-docsible, -nod: Do not generate .docsible file
--dry-run: Preview what would be generated without writing any files (analysis still performed)
--validate/--no-validate: Enable/disable markdown formatting validation (default: enabled)
--auto-fix: Automatically fix common markdown formatting issues (whitespace, tables)
--strict-validation: Fail generation if markdown validation errors are found (default: warn only)
π Content Sections:
--no-vars: Skip variable documentation (defaults, vars, argument_specs)
--no-tasks: Skip task lists and task details
--no-diagrams: Skip all Mermaid diagrams (flowcharts, sequence diagrams)
--simplify-diagrams: Show only high-level diagrams, hide detailed task flowcharts
--no-examples: Skip example playbook sections
--no-metadata: Skip role metadata, author, and license information
--no-handlers: Skip handlers section
--include-complexity: Include complexity analysis section in README
--minimal: Generate minimal documentation (enables all --no-* flags)
π¨ Templates:
--md-role-template, -rtpl, -tpl: Path to the role markdown template file
--md-collection-template, -ctpl: Path to the collection markdown template file
--hybrid: Use hybrid template (manual + auto-generated sections)
π Visualization:
--graph, -g: Generate Mermaid diagrams for role visualization
--comments, -com: Extract and include inline comments from task files in documentation
--task-line, -tl: Include source file line numbers for each task in generated documentation
π Analysis & Complexity:
--complexity-report: Include role complexity analysis in generated documentation
--simplification-report: Include detailed pattern analysis with simplification suggestions in documentation
--show-dependencies: Generate task dependency matrix table in documentation
--analyze-only: Analyze role complexity and display detailed metrics without generating documentation
π Repository Integration:
--repository-url, -ru: Repository base URL (used for standalone roles)
--repo-type, -rt: Repository type (github, gitlab, gitea, etc.)
--repo-branch, -rb: Repository branch name (e.g., main or master)
βοΈ Global Options:
--verbose, -v: Enable debug logging
--version: Show version
--help: Show help messageDocsible fetches information from the following files within the specified Ansible role:
defaults/*.yml/yaml: For default variablesvars/*.yml/yaml: For role-specific variablesmeta/main.yml/yaml: For role metadatatasks/*.yml/yaml: For tasks, including special task types and subfolders
Docsible works with Python 3.x and requires the following libraries:
- Click
- Jinja2
- PyYAML
- Pydantic
This tool works with several types of comments.
The tool read comments placed before a variable, only if it begin with specific tag:
# title: This tag will be used to populate the column Title of README.md. It is a short description of the variable
# required: This tag will be used to populate the column Required of README.md.
# choices: This optional tag will be used to populate the column Choices of the README.md.
The tool will read all the lines before each - name: of the tasks that begin with #.
All comments will be reported to the column Comments of the tasks tables.
For details on how to contribute, please read the Contributing Guidelines. Pull requests that do not follow the guidelines may be closed or require changes before being accepted.
This project is licensed under the MIT License. See the LICENSE file for more details.