<div># The hope is this one dictionary can define every aspect of the</div><div># test so that the failure condition test can be imported with this</div><div># one variable</div><div></div><div>test_details:</div><div> test_id: 001</div><div> test_name: "File does not exist"</div><div> test_fail_task: "Verify test exists"</div><div> test_fail_message: "FAIL: The file to be backed up does not exist"</div><div> </div><div> # Want to define role variables as shown below</div><div> # variable names and values change depending on the role</div><div> # and so need to be very dynamic</div><div></div><div> test_vars: </div><div> target_file: '/file/location'</div><div> target_dest: 'file/location2'</div><div> test_role: 'my_role'</div><div> </div><div># BEGIN REUSABLE BIT</div><div># All expected failing tests can reuse the same block below</div><div># if the test_vars are passed to the role as shown below</div><div><br></div><div><br></div><div>- name: testing block</div><div> block:</div><div> </div><div> - name: include role</div><div> ansible.builtin.include_role:</div><div> name: "{{ test_vars.test_role }}"</div><div> # Passing in the dictionary doesn't work like this</div><div> # need to strip out the "test_vars" level and just nest</div><div> # the level below under "vars:"</div><div> vars: "{{ test_vars }}" # << Want to add variables here</div><div> </div><div> rescue:</div><div><snip></div><div> always:</div><div><snip></div><div></div><div># --------------- So that it acts like this below</div><div><snip></div><div> - name: include role</div><div> ansible.builtin.include_role:</div><div> name: "{{ test_vars.test_role }}"</div><div> vars: </div><div> target_file: '/file/location'</div><div> target_dest: 'file/location2'</div><div> test_role: 'my_role'</div><div><snip></div><div> </div><div>lots more code below</div>