I have an ansible playbook which requires a JSON file to be passed as a --extra-vars (or -e ) from the command line. I would like to know if there is any way that I can add a validation task in my playbook to confirm that such a file is passed.
I have checked hostvars and did not find any parameter that stores such value or name of the file. It directly loaded the variables present inside the file.
I tried echo !! (to fetch the command history) using command and shell modules which didn't work either.
Sample command
ansible-playbook test.yml -e@input_vars.json
I want a task that will fail the execution if the JSON file is not passed in --extra-vars. Is it possible?