Registry / devops / ansible-pygments

ansible-pygments

JSON →
library0.1.2pypypiunverified

Ansible Pygments provides a Pygments lexer specifically designed to highlight Ansible output. It can be integrated into any application that uses Pygments for syntax highlighting, such as Sphinx documentation. The lexer is globally registered under the name `ansible-output` and also offers a Pygments style. The project is actively maintained with regular, typically minor, releases.

pip install ansible-pygments
INSTALL
IMPORT
SIG · ANSIBLE-PYGMENTS
A
ansible-pygments
devopspythonv0.1.2
Install
2.2s avg
Import
Disk
25MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.1.2 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.920 runs
installs and imports cleanly · install 0.0s · import 0.000s · 26.3MB
glibc
py 3.103.920 runs
installs and imports cleanly · install 2.2s · import 0.000s · 27MB
25MB installed
● package 25MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

AnsibleOutputLexer
from ansible_pygments import AnsibleOutputLexer
from ansible_pygments import AnsibleOutputLexer

This quickstart demonstrates how to use the `ansible-output` lexer with Pygments to highlight a string containing Ansible output and render it as HTML.

from pygments import highlight from pygments.lexers import get_lexer_by_name from pygments.formatters import HtmlFormatter ansible_output = """ [WARNING]: Unable to find '/nosuchfile' in expected paths (use -vvvvv to see paths) ok: [localhost] => { "msg": "Hello from Ansible!" } """ try: lexer = get_lexer_by_name('ansible-output') formatter = HtmlFormatter() highlighted_html = highlight(ansible_output, lexer, formatter) print(highlighted_html) except Exception as e: print(f"Error highlighting: {e}") print("Make sure 'ansible-pygments' and 'Pygments' are installed.")
Debug
Known issues
gotchaPygments, and by extension `ansible-pygments`, can be susceptible to Denial-of-Service (DoS) attacks if processing arbitrary, untrusted user inputs. Crafted inputs might lead to long processing times or excessive memory usage.
fix
When highlighting untrusted user input, ensure Pygments processes are terminated after a reasonable timeout and limit concurrent processes to prevent resource exhaustion.
affects: All versions
gotchaAs a 0.x.x version library, while actively maintained, `ansible-pygments` may introduce minor API changes or breaking modifications between patch or minor versions without adhering to strict semantic versioning (e.g., a 0.1.x to 0.2.x bump might include breaking changes).
fix
Pin `ansible-pygments` to exact versions in production environments (e.g., `ansible-pygments==0.1.2`) and review release notes carefully before upgrading.
affects: All 0.x.x versions
Upgrade
Version history
0.1.2latest on PyPI · released Jul 5, 2025
Audit
Dependencies
PygmentsrequiredProvides the core syntax highlighting framework.
Agent activity
13 hits · last 30 days
node
12
OpenAI (training)
1
Resources
ansible-pygments — pip install ansible-pygments · libregistry