AI Skill Report Card
Provisioning Infrastructure Ansible
YAML--- name: provisioning-infrastructure-ansible description: Provisions and configures infrastructure using Ansible playbooks and automation. Use when setting up servers, configuring services, or automating CLI/API operations. --- # Infrastructure Provisioning with Ansible
Quick Start
YAML# site.yml - Basic server setup --- - hosts: webservers become: yes tasks: - name: Install nginx package: name: nginx state: present - name: Start and enable nginx systemd: name: nginx state: started enabled: yes - name: Configure firewall ufw: rule: allow port: '80'
Run: ansible-playbook -i inventory site.yml
Recommendation▾
Add more concrete input/output examples showing before/after server states or actual command executions with their results
Workflow
- Inventory Setup - Define target hosts and groups
- Playbook Structure - Create role-based organization
- Variable Management - Set environment-specific configs
- Task Implementation - Write idempotent tasks
- Testing - Run with
--checkand--diff - Deployment - Execute against target environments
Progress checklist for complex deployments:
- Inventory configured with proper groups
- Variables defined per environment
- Playbooks tested with --check
- Backup/rollback plan in place
- Monitoring configured for new services
Recommendation▾
Include a complete inventory file example in Quick Start to make it immediately runnable
Examples
Example 1: Docker Container Deployment Input: Deploy application stack with database
YAML- name: Deploy app stack hosts: docker_hosts tasks: - name: Create app network docker_network: name: app_network - name: Deploy database docker_container: name: postgres image: postgres:13 networks: - name: app_network env: POSTGRES_DB: "{{ app_db_name }}"
Example 2: API Automation Input: Configure cloud resources via API
YAML- name: Provision AWS resources hosts: localhost tasks: - name: Create security group ec2_group: name: web-sg description: Web server security group rules: - proto: tcp ports: - 80 - 443 cidr_ip: 0.0.0.0/0
Recommendation▾
Expand the Testing section with specific commands and expected outputs for validation workflows
Best Practices
- Use roles for reusable components:
roles/nginx/tasks/main.yml - Encrypt secrets with ansible-vault:
ansible-vault encrypt group_vars/production/secrets.yml - Tag tasks for selective runs:
tags: [config, deploy] - Set fact caching for performance:
fact_caching = memory - Use handlers for service restarts:
notify: restart nginx - Template configurations with Jinja2:
template: src=nginx.conf.j2 dest=/etc/nginx/nginx.conf
Common Pitfalls
- Don't hardcode values - Use variables and templates instead
- Avoid shell/command modules when native modules exist
- Don't skip idempotency - Tasks should be safe to run multiple times
- Don't ignore changed_when - Set appropriate conditions for task reporting
- Avoid running as root unnecessarily - Use
becomeonly when needed - Don't mix environments - Keep staging/production inventories separate