I am very new to Ansible and having an issue. I want to run the module only if a condition is met but if the condition is failed, it should fail the task and report to user. Currently what I have done, it will only skip it rather than failing it.
Below is my code, I have the when condition to check and only run if result.stdout == 'valid' but I want to fail the task if its 'invalid'.Currently it just skips it if condition not met.
---
- name: Check Value
become: yes
shell: /usr/bin/python3 check.py
args:
chdir: "mydir/scripts/"
register: result
tags: data_merge
- name: Merge Data
become: yes
when: result.stdout == 'valid'
local_action:
module: some_module
provider: "{{some_provider}}"
role_path: "{{role_path}}"
run_once: true
tags: data_merge