I am running multiple ansible plays defined in YAML files.
In the last play I get the following error:
{"failed": true, "msg": "The conditional check 'ansible_os_family == \"RedHat\"' failed. The error was: error while evaluating conditional (ansible_os_family == \"RedHat\"): 'ansible_os_family' is undefined\n
Do I need to change anything with the facts gathering or something in the ansible.cfg
?
As per latest Ansible Version 2.5, to check if a variable is defined and depending upon this if you want to run any task, use undefined keyword. Show activity on this post. Strictly stated you must check all of the following: defined, not empty AND not None.
This module allows setting new variables. Variables are set on a host-by-host basis just like facts discovered by the setup module. These variables will be available to subsequent plays during an ansible-playbook run.
Add:
gather_facts: true
to your last play and try.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With