When to use this skill
Use this skill whenever the user wants to:
- Write playbooks, roles, and inventories; run ad-hoc commands or playbooks
- Use modules (package, copy, template, service, user, etc.) to manage configuration and deployment
- Handle variables, conditionals, loops, and error handling
How to use this skill
- Playbook: YAML defines hosts, tasks, handlers, and vars; roles organize reusable tasks and templates.
- CLI:
ansible-playbook playbook.yml、ansible -m ping all; inventory uses INI or YAML; credentials use vault or SSH keys. - Environment: the control machine requires Python; target machines must be reachable via SSH; optionally Ansible Tower/AWX for scheduling and auditing.
Best Practices
- Use roles and group_vars/host_vars for layering; avoid a single large playbook.
- Encrypt sensitive data with ansible-vault; make tasks idempotent using state and conditions.
- Define clear failure handling (ignore_errors, block/rescue); logs and tags facilitate troubleshooting.
Keywords
ansible, playbook, role, inventory, automation, configuration management