Ansible
One git checkout drops a shared AI coding setup (skills, subagents, MCP servers, OpenSpec scaffolding) into any project, across Claude Code, Kilo, OpenCode, Codex, and Copilot.
npx -y skills add Lukk17/agent-standards --skill ansibleAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
One thing to look at
- 0 stars0 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.
What its author says it does
Copied from the file, not written here
Ansible role structure, idempotency, vault, molecule testing, and CI standards for infrastructure automation playbooks.
SKILL.md
7.8 KB, as published. Nobody here has run it
Ansible Standards
Core Execution Directives
- Treat all LLM generated Ansible modules, collections, and parameters as potentially hallucinated.
- Enforce the Zero-Trust Prompt Engineering protocol for every Ansible task generation.
- Append a Zero-Trust directive demanding mandatory web searches for current Ansible module documentation and live configuration schemas.
- Implement a Fail-Fast directive forcing the agent to halt execution and refuse to answer if official Ansible documentation cannot be retrieved via live search.
- Require exact confidence percentage scores for every module parameter and configuration detail provided.
- Mandate that the agent provides direct, working links to the official Ansible documentation used to ground the code.
Playbook and Role Architecture
- Structure all code into Ansible Roles instead of monolithic playbooks.
- Require the agent to generate
meta/main.ymlfor every role with explicitly defined dependencies. - Use Fully Qualified Collection Names (FQCN) for all modules.
- Separate configuration data from execution logic using
host_varsandgroup_vars. - Keep task files concise and focused on a single domain of responsibility.
Variable and Secret Management
- Never hardcode secrets, passwords, API keys, or tokens in plain text.
- Require the agent to use Ansible Vault for all sensitive variables.
- Prefix all role variables with the role name to prevent namespace collisions.
- Define default variables in
defaults/main.ymland override only when necessary. - Validate variable types and constraints at the beginning of roles using the
assertmodule.
State and Idempotency
- Ensure every generated task is strictly idempotent.
- Restrict the use of the
commandorshellmodules strictly to scenarios where no dedicated module exists. - When
shellorcommandmodules must be used, requirecreatesorremovesparameters to guarantee idempotency. - Do not use the
changed_whenandfailed_whenparameters to artificially mask non-idempotent behavior.
Security Standards
- Execute tasks with the least privilege required.
- Apply
becomeexplicitly only on tasks that require root privileges. - Do not apply
becomeat the playbook level unless completely unavoidable. - Explicitly define
become_userwhen switching to non-root system accounts. - Defend against injection attacks by enforcing parameterized inputs and quoting variables properly when passed to shell tasks.
Linting and Validation
- Mandate the use of
ansible-lintfor all generated code to ensure compliance. - Require strict adherence to YAML formatting standards.
- Generate Molecule test scenarios for testing role execution.
- Require
verify.ymlplaybooks to confirm infrastructure state post-execution.
Git and Version Control
- Configure central standards repositories as read-only.
- Use
git checkout remote/master -- path/to/filesto extract specific Ansible AI configuration files into projects. - Document all required external collections in
requirements.yml. - Write task names as clear, human-readable descriptions of the desired state.
Multi-OS Provisioning Architecture
- Use the
ansible_os_familyoransible_distributiongathered facts to dynamically route execution to OS-specific task files. - Abstract all system packages into OS-specific variable files loaded via the
include_varsmodule. Never hardcode package names directly in task files. - Explicitly invoke the exact package manager module for the target OS:
- Debian/Ubuntu: Use
ansible.builtin.apt - Arch Linux: Use
community.general.pacman - Fedora/RHEL: Use
ansible.builtin.dnf - Windows: Use
chocolatey.chocolatey.win_chocolatey. Do not useansible.windows.win_chocolatey. - macOS: Use
community.general.homebrew
- Debian/Ubuntu: Use
Error Recovery
Use block / rescue / always for any task group that modifies system state and may need rollback:
- block:
- name: Deploy application
# ... tasks
rescue:
- name: Rollback on failure
# ... rollback tasks
always:
- name: Send notification
# ... notification tasks
- The
rescueblock must restore the system to a known-good state and log the failure with the error message. - The
alwaysblock must run cleanup tasks (remove temp files, release locks) regardless of success or failure.
Performance Optimisation
- Enable SSH pipelining in
ansible.cfg(pipelining = True) to reduce SSH connection overhead for multi-task playbooks. - Enable ControlPersist via SSH multiplexing in
ansible.cfgto reuse SSH connections:
[ssh_connection]
pipelining = True
ssh_args = -o ControlMaster=auto -o ControlPersist=60s
- Use
asyncwithpoll: 0for long-running tasks (package installs, service restarts), then useasync_statusto wait for completion, allowing other tasks to run in parallel. - Enable fact caching (
fact_caching = jsonfile) for large inventories to avoid re-gathering facts on every run.
Dynamic Inventory
- Use the official cloud provider inventory plugins (not deprecated scripts) for dynamic inventory:
- AWS:
amazon.aws.aws_ec2 - GCP:
google.cloud.gcp_compute - Azure:
azure.azcollection.azure_rm
- AWS:
- Store inventory plugin configuration in the
inventory/directory as YAML files committed to the repository. - Filter dynamic inventory using
filtersandkeyed_groupsto create logical host groups without hardcoding IPs.
AWX / Ansible Automation Platform (AAP)
- Define all automation as reusable Job Templates in AWX/AAP; do not run ad-hoc playbooks against production.
- Use Survey Variables in Job Templates for operator-supplied runtime parameters; define allowed values and defaults.
- Use Credentials objects in AWX/AAP for all secrets; never pass secrets as extra variables.
- Name Job Templates using the convention:
[Environment] Role/Action Description(e.g.,[Prod] Deploy Web Application).
Collection Dependency Pinning
- Pin all Ansible Galaxy collections to exact versions in
requirements.yml:
collections:
- name: community.general
version: "9.x.x"
- name: amazon.aws
version: "8.x.x"
- Run
ansible-galaxy collection install -r requirements.yml --forcein CI to ensure reproducible collection installs. - Never use
version: "*"or omit the version field inrequirements.yml.
Testing Pipeline Stages
Run automation through the following gate sequence in CI before any production execution:
- Lint:
ansible-lint: zero violations. - Syntax check:
ansible-playbook --syntax-check: zero errors. - Dry run:
ansible-playbook --check --diffagainst a staging inventory: review diff output. - Molecule test: Full role execution + idempotency check in an isolated container/VM.
- Verify: Run
verify.ymlassertions to confirm the expected infrastructure state. - Promote: Merge to main produces a release artifact or a ready-to-run AWX/AAP Job Template; it does not execute
against production by itself. Production execution requires an explicit approval gate, such as an AWX/AAP Job
Template with an approval node, or a manually triggered
workflow_dispatchrun.