Hello colleagues,
I am currently facing an issue with a survey workflow in Ansible that requires conditional checks and subsequent tasks execution based on the survey results.
Here’s the scenario:
I have a survey that determines which of the two checks (or both) should be executed. Depending on the survey result, either check-useast
, check-eucentral
, or both need to be run. Upon successful execution of these checks, the next corresponding step (either adserver-useast
or adserver-eucentral
) should be executed.
This is the behavior I desire, and it works as expected. However, there is one issue. When only one region needs to be executed, the other check (which is not supposed to run) fails as expected but causes the job to be marked as failed. This is problematic because, in reality, only one route should be executed based on the survey results.
What I want to achieve is to make these checks non-determinant, meaning that the overall workflow result should reflect the execution of the appropriate templates regardless of the failed check for the unused route.
Here’s a visual representation of the workflow for better understanding:
Here I share the playbook of one of the two checks.
---
- name: Verify if useast is in the selection
hosts: localhost
gather_facts: no
tasks:
- name: Check if useast is selected
fail:
msg: "useast not selected"
when: "'useast' not in regions"
register: useast_check
- name: Debug output for useast
debug:
msg: "useast is selected"
when: "'useast' in regions"
Could anyone provide guidance on how to configure the checks so that the job does not fail when one of the checks fails due to it not being required?
Thank you for your assistance!