Ansible Integration
Vapor provides seamless Ansible integration for infrastructure automation, configuration management, and orchestration. Execute playbooks, manage inventory, and track execution history through an intuitive interface.
Prerequisites
- Ansible 2.9+ installed on the system
- SSH access to managed nodes
- Properly configured ansible.cfg
- Python on managed nodes
Navigating to Ansible
- From the main menu, click on Ansible
- Three main tabs are available:
- Playbooks & Templates
- Inventory
- Executions
Playbooks Management
The Playbooks tab manages Ansible playbooks and templates.
Playbook Library
View all available playbooks:
- Playbook name and path
- Description (from metadata)
- Last modified time
- Execution count
- Tags available
- Variables required
Uploading Playbooks
- Click Upload Playbook
- Select method:
- File Upload: Upload .yml files
- Git Repository: Clone from Git
- Direct Entry: Write in editor
- Configure playbook location
- Click Save
Playbook Organization
Organize playbooks in directories:
ansible/
├── playbooks/
│ ├── webserver/
│ │ ├── install.yml
│ │ └── configure.yml
│ ├── database/
│ │ ├── mysql.yml
│ │ └── postgresql.yml
│ └── maintenance/
│ ├── update.yml
│ └── backup.yml
└── roles/
└── common/
Executing Playbooks
Quick Execute
- Click Run on a playbook
- Select inventory or hosts
- Click Execute
Advanced Execute
- Click Advanced Run
- Configure execution:
Target Selection
- Inventory: Select inventory file
- Limit: Specific hosts/groups
- Tags: Run specific tags only
- Skip Tags: Exclude certain tags
Variables
- Extra Variables: Key-value pairs or JSON
- Variable Files: Upload vars files
- Vault Password: For encrypted vars
Execution Options
- Check Mode: Dry run without changes
- Diff Mode: Show what will change
- Verbose Level: Debug output level
- Forks: Parallel execution threads
- Timeout: Connection timeout
- Become: Privilege escalation
SSH Options
- Private Key: SSH key file
- SSH Password: For password auth
- Become Password: sudo/su password
- Connection Type: ssh, local, docker
- Click Execute
Playbook Templates
Vapor provides pre-built templates for common tasks:
System Templates
- System Update: Update all packages
- Security Hardening: Apply security baseline
- User Management: Create/manage users
- Firewall Setup: Configure iptables/firewalld
- Time Sync: Configure NTP/Chrony
Application Templates
- Web Server: Nginx/Apache setup
- Database Server: MySQL/PostgreSQL
- Container Runtime: Docker/Podman
- Kubernetes Node: Join K8s cluster
- Monitoring Agent: Prometheus/Grafana
Network Templates
- Network Configuration: Interface setup
- DNS Configuration: Resolver settings
- VPN Setup: OpenVPN/WireGuard
- Load Balancer: HAProxy/Nginx
Custom Templates
Create your own templates:
- Click Create Template
- Configure template:
- Name and description
- Base playbook
- Default variables
- Required inputs
- Save template for reuse
Playbook Development
Integrated Editor
Edit playbooks directly in Vapor:
- YAML syntax highlighting
- Auto-completion
- Syntax validation
- Module documentation
- Variable references
Testing Playbooks
- Use Check Mode first
- Test on single host
- Review execution output
- Apply to production
Inventory Management
The Inventory tab manages Ansible inventory.
Inventory Types
Static Inventory
Traditional INI or YAML format:
[webservers]
web1.example.com ansible_host=192.168.1.10
web2.example.com ansible_host=192.168.1.11
[databases]
db1.example.com ansible_host=192.168.1.20
db2.example.com ansible_host=192.168.1.21
[all:vars]
ansible_user=admin
ansible_ssh_private_key_file=/path/to/key
Dynamic Inventory
Generate inventory from sources:
- Cloud Providers: AWS, Azure, GCP
- Virtualization: VMware, Libvirt
- Containers: Docker, Kubernetes
- CMDB: ServiceNow, NetBox
- Custom Scripts: Python/Shell scripts
Managing Inventory
Creating Inventory
- Click Create Inventory
- Choose type:
- Manual: Enter hosts manually
- Import: Upload inventory file
- Dynamic: Configure source
- Add hosts and groups
- Set variables
- Click Save
Editing Inventory
- Click on inventory name
- Modify in editor:
- Add/remove hosts
- Create groups
- Set host/group variables
- Configure connections
- Validate syntax
- Save changes
Host Management
For each host:
- Test Connection: Verify SSH access
- Gather Facts: Collect system information
- View Variables: See all applicable vars
- Run Command: Execute ad-hoc commands
Host Groups
Organize hosts into groups:
- Nested groups support
- Group variables
- Pattern matching
- Dynamic group membership
Variables
Variable Precedence
From lowest to highest:
- All group vars
- Parent group vars
- Child group vars
- Host vars
- Host facts
- Play vars
- Task vars
- Extra vars
Managing Variables
- Group Variables: Apply to all hosts in group
- Host Variables: Specific to individual hosts
- Global Variables: Apply to entire inventory
- Vault Variables: Encrypted sensitive data
Execution History
The Executions tab shows all Ansible runs.
Execution List
Each execution shows:
- Execution ID
- Playbook name
- Start time and duration
- Status (Running, Success, Failed)
- User who initiated
- Affected hosts
Execution Details
Click on an execution to view:
Summary
- Total hosts targeted
- Successful/failed/unreachable
- Tasks executed
- Changes made
- Execution time
Output
- Real-time streaming output
- Color-coded by status
- Task-by-task breakdown
- Error messages highlighted
- Searchable logs
Host Results
- Per-host status
- Changed tasks
- Failed tasks
- Skipped tasks
- Fact gathering results
Artifacts
- Generated files
- Reports
- Logs
- Configuration backups
Re-running Executions
- Click Re-run on execution
- Modify parameters if needed
- Execute again
Scheduling
Schedule playbook executions:
- Click Schedule on playbook
- Configure:
- Frequency: Once, Daily, Weekly, Monthly
- Time: Execution time
- Parameters: Variables and options
- Notifications: Email on completion
- Click Create Schedule
Ad-hoc Commands
Execute quick commands without playbooks:
- Click Ad-hoc Command
- Select:
- Target hosts/groups
- Module to use
- Module arguments
- Execution options
- Click Run
Common ad-hoc uses:
- Ping connectivity test
- Gather facts
- Copy files
- Restart services
- Install packages
- Check disk space
Best Practices
Playbook Design
- Idempotency: Ensure playbooks can run multiple times
- Error Handling: Use blocks and rescue
- Variable Usage: Parameterize for flexibility
- Role-Based: Organize into reusable roles
- Documentation: Comment complex tasks
Security
- Vault Usage: Encrypt sensitive data
- Key Management: Use SSH keys, not passwords
- Least Privilege: Minimize sudo usage
- Audit Trail: Log all executions
- Input Validation: Sanitize user inputs
Performance
- Parallel Execution: Adjust forks appropriately
- Fact Caching: Cache facts when possible
- Pipelining: Enable SSH pipelining
- Async Tasks: Use async for long operations
- Conditional Execution: Skip unnecessary tasks
Troubleshooting
Connection Issues
- Verify SSH connectivity
- Check SSH keys/passwords
- Ensure Python installed on target
- Verify ansible_user is correct
- Check firewall rules
Playbook Failures
- Review error messages
- Check syntax with ansible-playbook --syntax-check
- Verify variables are defined
- Test with increased verbosity (-vvv)
- Check module documentation
Performance Problems
- Increase forks for parallelism
- Enable fact caching
- Use async for long tasks
- Optimize gathering facts
- Consider push vs pull mode
Variable Issues
- Check variable precedence
- Verify variable names
- Review group_vars/host_vars
- Check for typos
- Use debug module to inspect
Integration with Vapor
System Integration
Vapor can generate Ansible inventory from:
- Docker containers
- Virtual machines
- Kubernetes nodes
- Network devices
Workflow Automation
Combine Vapor features:
- Create VMs with Vapor
- Auto-generate inventory
- Run configuration playbooks
- Monitor with Vapor metrics
API Integration
Use Vapor API for automation:
# Example: Trigger playbook via API
import requests
response = requests.post(
"http://vapor/api/v1/ansible/playbooks/execute",
json={
"playbook": "webserver.yml",
"inventory": "production",
"extra_vars": {"version": "1.2.3"}
},
headers={"Authorization": "Bearer TOKEN"}
)