--- # Provider-aware test execution with infrastructure management # This task file handles the complete lifecycle: # 1. Provision infrastructure (VM/instance based on provider) # 2. Run test (provider-agnostic) # 3. Collect results # 4. Cleanup infrastructure - name: "Test: {{ test_item.name }}" block: # =========================================== # PROVISION INFRASTRUCTURE (Provider-specific) # =========================================== # LIBVIRT: Create linked clone from golden image - name: "[libvirt] Provision VM from golden image" include_role: name: provision_vm vars: vm_name: "test-{{ test_item.name }}-{{ ansible_date_time.epoch }}" test_name: "{{ test_item.name }}" when: provider == 'libvirt' # AWS: Launch EC2 instance (future implementation) - name: "[aws] Launch EC2 instance" debug: msg: "TODO: Launch EC2 instance for {{ test_item.name }}" when: provider == 'aws' # TODO: Add actual AWS provisioning role when ready # include_role: # name: provision_aws_instance # vars: # instance_name: "test-{{ test_item.name }}-{{ ansible_date_time.epoch }}" # AZURE: Create VM (future implementation) - name: "[azure] Create Azure VM" debug: msg: "TODO: Create Azure VM for {{ test_item.name }}" when: provider == 'azure' # TODO: Add actual Azure provisioning role when ready # =========================================== # RUN TEST (Provider-agnostic) # =========================================== - name: "Execute test: {{ test_item.name }}" include_role: name: run_test vars: test_name: "{{ test_item.name }}" test_repo_url: "{{ test_item.repo_url }}" test_repo_branch: "{{ test_item.branch | default(default_test_branch) }}" test_timeout: "{{ test_item.timeout | default(default_test_timeout) }}" # Record success - name: Record test success set_fact: test_results: "{{ test_results + [{'name': test_item.name, 'status': 'passed'}] }}" rescue: # Record failure - name: Record test failure set_fact: test_results: "{{ test_results + [{'name': test_item.name, 'status': 'failed', 'error': ansible_failed_result.msg | default('Unknown error')}] }}" - name: Display test failure debug: msg: "Test {{ test_item.name }} FAILED: {{ ansible_failed_result.msg | default('Unknown error') }}" always: # =========================================== # CLEANUP INFRASTRUCTURE (Provider-specific) # =========================================== # LIBVIRT: Destroy VM clone - name: "[libvirt] Cleanup VM" include_role: name: cleanup_vm vars: vm_name: "test-{{ test_item.name }}-{{ ansible_date_time.epoch }}" when: provider == 'libvirt' ignore_errors: true # AWS: Terminate EC2 instance (future implementation) - name: "[aws] Terminate EC2 instance" debug: msg: "TODO: Terminate EC2 instance for {{ test_item.name }}" when: provider == 'aws' ignore_errors: true # TODO: Add actual AWS cleanup role when ready # AZURE: Delete VM (future implementation) - name: "[azure] Delete Azure VM" debug: msg: "TODO: Delete Azure VM for {{ test_item.name }}" when: provider == 'azure' ignore_errors: true # TODO: Add actual Azure cleanup role when ready - name: Test completed debug: msg: "Finished test: {{ test_item.name }}"