Skill 详情
ansible-validator
Useful DevOps automation validation specialty, limited to existing Ansible code.
使用前先检查
自动化审核只检查相关性,不代表安全审查或推荐。使用前请阅读来源中的说明。
SKILL.md
这段内容是审核时保存的快照。外部来源才是完整且最新的版本。
--- name: ansible-validator description: Validate, lint, audit, or debug Ansible playbooks, roles, inventories, FQCN, tasks. --- # Ansible Validator ## Overview Comprehensive toolkit for validating, linting, and testing Ansible playbooks, roles, and collections. This skill provides automated workflows for ensuring Ansible code quality, syntax validation, dry-run testing with check mode and molecule, and intelligent documentation lookup for custom modules and collections with version awareness. **Default behavior:** When validating any Ansible role with a `molecule/` directory, attempt Molecule automatically using `bash scripts/test_role.sh <role-path>`. If Molecule cannot run due to environment/runtime limits, mark Molecule as `BLOCKED`, report why, and continue all non-Molecule validation steps. ## Trigger Guidance Use this skill when the request is about validating or debugging existing Ansible code, not generating new code. Common trigger phrases: - "validate this playbook" - "lint this role" - "why is ansible-lint failing" - "run check mode safely" - "test this role with molecule" - "find security issues in these Ansible files" - "module not found in this collection" ## When to Use This Skill Apply this skill when encountering any of these scenarios: - Working with Ansible files (`.yml`, `.yaml` playbooks, roles, inventories, vars) - Validating Ansible playbook syntax and structure - Linting and formatting Ansible code - Performing dry-run testing with `ansible-playbook --check` - Testing roles and playbooks with Molecule - Debugging Ansible errors or misconfigurations - Understanding custom Ansible modules, collections, or roles - Ensuring infrastructure-as-code best practices - Security validation of Ansible playbooks - Version compatibility checks for collections and modules ## Preflight (Run First) Run preflight before validation to avoid dead ends: ```bash bash scripts/setup_tools.sh ``` Command path assumption: run commands from this skill root (`devops-skills-plugin/skills/ansible-validator`) or use absolute paths. Preflight requirements: - Baseline validation: `ansible`, `ansible-playbook`, `ansible-lint` (plus `yamllint` recommended) - Molecule execution: `molecule` plus an available runtime (`docker` or `podman`) - Security scanning: `checkov` (wrapper can bootstrap if missing) Deterministic fallback rules: - If baseline tools are missing but Python + pip are available, wrapper scripts bootstrap temporary environments automatically. - If wrapper bootstrap fails (offline index, pip failure, missing Python), run direct commands for available tools, mark missing stages as `BLOCKED`, and continue. - If Molecule runtime is unavailable (Docker/Podman missing or daemon not running), skip Molecule execution, mark as `BLOCKED`, and continue remaining stages. ## Wrapper vs Direct Command Routing Use wrappers by default for consistent behavior and fallback handling. | Validation scenario | Default command | Use direct command when | Fallback if command cannot run | |---|---|---|---| | Playbook syntax/lint | `bash scripts/validate_playbook.sh <playbook.yml>` | User asks for a single focused check only (`ansible-playbook --syntax-check`, `ansible-lint`, or `yamllint`) | Run any available direct checks and report skipped checks as `BLOCKED` | | Role structural validation | `bash scripts/validate_role.sh <role-dir>` | User asks only for specific sub-checks (for example, structure only) | Run structure/YAML checks that are possible and report missing stages | | Role Molecule execution | `bash scripts/test_role.sh <role-dir> [scenario]` | User explicitly asks for manual stage-by-stage Molecule commands | Mark Molecule `BLOCKED` with reason and continue non-Molecule role checks | | Security scanning | `bash scripts/validate_playbook_security.sh <path>` or `bash scripts/validate_role_security.sh <path>` plus `bash scripts/scan_secrets.sh <path>` | User requests raw Checkov output formatting or custom flags | Run在 GitHub 阅读完整来源 (打开外部页面)