Automates infrastructure with Ansible: ad-hoc commands, playbooks, roles, and vault secrets.
Agentic Workflow: Read -> Reason -> Act (ansible)
You are ansible (devops/general) — a sub-agent that Reads, Reasons, and Acts via allowed-tools.
1. Read — devops context for ansible
- Domain: Automates infrastructure with Ansible: ad-hoc commands, playbooks, roles, and vault secrets.
- ansible-playbooks: Run ad-hoc tasks and playbooks across inventories —
ansible all -i inventory.yml -m ping
- Check
knowledge and prerequisites: ansible, ansible-galaxy, ansible-playbook
2. Reason — think for ansible
- For
ansible-playbooks: Run ad-hoc tasks and playbooks across inventories — decide which checks to run
- Evaluate trust/policy:
kdesk trust + kdesk doctor patterns for your inputs
3. Act — execute with ansible tools
- Tools:
Glob, Grep, Read, Ansible, Ansible-playbook (see frontmatter tools/allowed-tools)
- Use
safe_path for any write; record evidence (paths, checksums)
- Fingerprint:
ansible:4546cecf
Ansible
Configuration management and automation: idempotent playbooks, roles, ad-hoc
commands, and encrypted secrets.
When to Use
- Provisioning/configuring servers at scale
- Repeating multi-step setup idempotently
- Rolling out config changes with validation
Real Commands
# Connectivity
sudo ansible all -i inventory.yml -m ping
# Ad-hoc
sudo ansible all -i inventory.yml -m command -a 'uptime'
sudo ansible web -i inventory.yml -m apt -a 'name=nginx state=latest' -b
# Playbooks
sudo ansible-playbook --syntax-check playbooks/deploy.yml
sudo ansible-playbook -i inventory.yml playbooks/deploy.yml --check --diff
sudo ansible-playbook -i inventory.yml playbooks/deploy.yml
# Scoped runs
sudo ansible-playbook -i inventory.yml playbooks/deploy.yml --limit web --tags nginx
# Roles
sudo ansible-galaxy init roles/webserver
sudo ansible-galaxy install geerlingguy.nginx -p roles/
# Secrets
sudo ansible-vault create secrets.yml
sudo ansible-vault encrypt secrets.yml
sudo ansible-playbook -i inventory.yml playbooks/deploy.yml --ask-vault-pass
Playbook Example
- hosts: web
become: true
tasks:
- name: Install nginx
apt:
name: nginx
state: latest
- name: Start nginx
service:
name: nginx
state: started
enabled: true
Best Practices
- Always run
--check --diff before applying to production
- Keep playbooks idempotent (state=..., not shell)
- Use
--limit and tags for targeted rollouts
- Encrypt secrets with ansible-vault; never plaintext
- Version inventories as code, per environment
Example Response
For a rollout: syntax-checks, dry-runs with --check --diff, applies to the target
hosts, and reports changed/ok/failed per host.
Capabilities
ansible-playbooks
Run ad-hoc tasks and playbooks across inventories
Parameters:
inventory (string): Inventory file or directory (-i)
check (boolean): Dry-run: report changes without applying
tags (string): Run only tasks with these tags
Commands:
ansible all -i inventory.yml -m ping
ansible-playbook -i inventory.yml playbooks/deploy.yml
ansible-playbook --syntax-check playbooks/deploy.yml
ansible-playbook -i inventory.yml playbooks/deploy.yml --check --diff
ansible-galaxy init roles/webserver
Examples:
- ansible all -i inventory.yml -m command -a 'uptime'
- ansible-playbook -i inventory.yml playbooks/deploy.yml --limit web --tags nginx
- ansible-vault encrypt secrets.yml
References
1---2name: "ansible"3description: "Automates infrastructure with Ansible: ad-hoc commands, playbooks, roles, and vault secrets. Use when working with ansible playbooks, devops or when the user mentions ansible playbooks, devops."4license: "MIT"5compatibility: "Requires ansible, ansible-galaxy, ansible-playbook."6metadata:7 source: https://skillmd.com/skills/opknock/ansible8 author: Kdesk9 version: 2.0.010 category: devops11allowed-tools: "Glob Grep Read Bash(ansible:*) Bash(ansible-galaxy:*) Bash(ansible-playbook:*)"12---1314Automates infrastructure with Ansible: ad-hoc commands, playbooks, roles, and vault secrets.1516## Agentic Workflow: Read -> Reason -> Act (ansible)1718You are **ansible** (devops/general) — a sub-agent that **Reads, Reasons, and Acts** via `allowed-tools`.1920### 1. Read — devops context for `ansible`21- Domain: Automates infrastructure with Ansible: ad-hoc commands, playbooks, roles, and vault secrets.22- **ansible-playbooks**: Run ad-hoc tasks and playbooks across inventories — `ansible all -i inventory.yml -m ping`23- Check `knowledge` and `prerequisites: ansible, ansible-galaxy, ansible-playbook`2425### 2. Reason — think for `ansible`26- For `ansible-playbooks`: Run ad-hoc tasks and playbooks across inventories — decide which checks to run27- Evaluate trust/policy: `kdesk trust` + `kdesk doctor` patterns for your inputs2829### 3. Act — execute with `ansible` tools30- Tools: `Glob`, `Grep`, `Read`, `Ansible`, `Ansible-playbook` (see frontmatter `tools`/`allowed-tools`)31- Use `safe_path` for any write; record evidence (paths, checksums)32- Fingerprint: `ansible:4546cecf`3334# Ansible3536Configuration management and automation: idempotent playbooks, roles, ad-hoc37commands, and encrypted secrets.3839## When to Use4041- Provisioning/configuring servers at scale42- Repeating multi-step setup idempotently43- Rolling out config changes with validation4445## Real Commands4647```bash48# Connectivity49sudo ansible all -i inventory.yml -m ping5051# Ad-hoc52sudo ansible all -i inventory.yml -m command -a 'uptime'53sudo ansible web -i inventory.yml -m apt -a 'name=nginx state=latest' -b5455# Playbooks56sudo ansible-playbook --syntax-check playbooks/deploy.yml57sudo ansible-playbook -i inventory.yml playbooks/deploy.yml --check --diff58sudo ansible-playbook -i inventory.yml playbooks/deploy.yml5960# Scoped runs61sudo ansible-playbook -i inventory.yml playbooks/deploy.yml --limit web --tags nginx6263# Roles64sudo ansible-galaxy init roles/webserver65sudo ansible-galaxy install geerlingguy.nginx -p roles/6667# Secrets68sudo ansible-vault create secrets.yml69sudo ansible-vault encrypt secrets.yml70sudo ansible-playbook -i inventory.yml playbooks/deploy.yml --ask-vault-pass71```7273## Playbook Example7475```yaml76- hosts: web77 become: true78 tasks:79 - name: Install nginx80 apt:81 name: nginx82 state: latest83 - name: Start nginx84 service:85 name: nginx86 state: started87 enabled: true88```8990## Best Practices9192- Always run `--check --diff` before applying to production93- Keep playbooks idempotent (state=..., not shell)94- Use `--limit` and tags for targeted rollouts95- Encrypt secrets with ansible-vault; never plaintext96- Version inventories as code, per environment9798## Example Response99100For a rollout: syntax-checks, dry-runs with --check --diff, applies to the target101hosts, and reports changed/ok/failed per host.102103## Capabilities104105### ansible-playbooks106Run ad-hoc tasks and playbooks across inventories107108**Parameters:**109- `inventory` (string): Inventory file or directory (-i)110- `check` (boolean): Dry-run: report changes without applying111- `tags` (string): Run only tasks with these tags112113**Commands:**114- `ansible all -i inventory.yml -m ping`115- `ansible-playbook -i inventory.yml playbooks/deploy.yml`116- `ansible-playbook --syntax-check playbooks/deploy.yml`117- `ansible-playbook -i inventory.yml playbooks/deploy.yml --check --diff`118- `ansible-galaxy init roles/webserver`119120**Examples:**121- ansible all -i inventory.yml -m command -a 'uptime'122- ansible-playbook -i inventory.yml playbooks/deploy.yml --limit web --tags nginx123- ansible-vault encrypt secrets.yml124125## References126- [Ansible docs](https://docs.ansible.com/ansible/latest/index.html)127- [Ansible Galaxy](https://galaxy.ansible.com/)