9

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?

helloV
  • 50,176
  • 7
  • 137
  • 145
Souciance Eqdam Rashti
  • 3,143
  • 3
  • 15
  • 31

2 Answers2

19

Add:

gather_facts: true

to your last play and try.

helloV
  • 50,176
  • 7
  • 137
  • 145
  • Maybe this has changed because I don't have to add gather_facts: true in order for the conditional when: ansible_os_family == 'RedHat' to work. If there is an explicit gather_facts: false however, then you will get the error reported above. – pforsthoff Oct 11 '18 at 16:05
  • 2
    @pforsthoff `gather_facts` by default is `true`. The OP explicitly set that to `false`, so either removing it or setting it to `true` will work. – helloV Oct 11 '18 at 23:46
1

In addition to the answer by @helloV :

A note to self and others, gathering = works along with gather_facts::

# smart - gather by default, but don't regather if already gathered
# implicit - gather by default, turn off with gather_facts: False
# explicit - do not gather by default, must say gather_facts: True
# gathering = explicit
arcolife
  • 386
  • 1
  • 3
  • 12