--- # One drift case: seeds the live VM config the REST lookup would return, runs the role's drift # detection with the inputs the caller sets on the include, and asserts each expected drift fact. # Input: pve_vm_test_case (name, config, expect: a mapping of drift dimension to true or false, # needs_update for the combined result). - name: "Seed the live VM config, case {{ pve_vm_test_case.name }}" ansible.builtin.set_fact: __pve_vm_config: "{{ pve_vm_test_case.config }}" - name: "Detect configuration drift, case {{ pve_vm_test_case.name }}" ansible.builtin.include_role: name: mortis.kamino.pve_vm tasks_from: detect_drift - name: "Assert the drift facts, case {{ pve_vm_test_case.name }}" ansible.builtin.assert: that: (lookup('ansible.builtin.vars', pve_vm_test_fact) | bool) == (item.value | bool) fail_msg: "{{ pve_vm_test_fact }} is {{ lookup('ansible.builtin.vars', pve_vm_test_fact) }}, expected {{ item.value }}" quiet: true vars: pve_vm_test_fact: "{{ '__pve_vm_needs_update' if item.key == 'needs_update' else '__pve_vm_drift_' ~ item.key }}" loop: "{{ pve_vm_test_case.expect | dict2items }}" loop_control: label: "{{ item.key }}"