Ansible playbooks automate VM lifecycle operations for Citrix VDA deployment. These are automation scripts written in YAML that define a series of tasks to be executed on remote systems. They describe the desired state of your infrastructure and document the steps needed to achieve it. How playbooks work: A playbook contains one or more “plays,” each targeting specific hosts and executing a sequence of tasks:
-
Inventory defines which hosts to target (e.g., the
hostsgroup containing your physical Mac machines) - Tasks specify actions to perform (deploy VM, install software, configure settings)
- Variables customize behavior for different environments or use cases
- Handlers respond to changes (restart services after configuration updates)
Core Ansible Playbook Examples
VM Deploy
Delete a single VM
Delete multiple VMs matching a specific naming convention
create_image.yml to create versioned images
2. Store images in your OCI registry
3. To restore: Deploy new VMs from the backed-up image version
VM deletion playbook workflow:
- Deletes VM from Orka Engine
- Frees up resources on host
Create a VM Image
/scripts directory
2. Scripts will be executed in alphabetical order
3. Example scripts:
Cache a VM Image
pull_image.yml automatically caches the image on all hosts in the inventory.
Recreate a VM Image
This implementation doesn’t have a dedicated playbook. To refresh VMs with a new image:- Delete existing VM
- Create a new VM from specified image
Playbook customization for your environment
The Ansible playbook examples referenced throughout this document will require additional customization to match your infrastructure and organizational requirements. Environment-specific variables: Create agroup_vars/all.yml file with the following settings as an example:
Test Basic VM Lifecycle Operations
Before deploying to production, validate all playbook operations in a test environment.Test sequence:
- Test connectivity
- Test image operations
- Test VM deployment
- Test VDA registration
- Test VM lifecycle
- Test image creation
- Test VM recreation
- Test VM deletion
- Test end-to-end user sessions
- Use verbose output for troubleshooting: