### Summary

When I define `failed_when:` condition in the task using `add_host`, it caused an error that the variable was not found.


### Issue Type

Bug Report

### Component Name

task

### Ansible Version

```console
$ ansible --version
ansible [core 2.11.2] 
  config file = /etc/ansible/ansible.cfg
  configured module search path = ['/var/lib/awx/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python3.8/site-packages/ansible
  ansible collection location = /var/lib/awx/.ansible/collections:/usr/share/ansible/collections
  executable location = /usr/bin/ansible
  python version = 3.8.6 (default, Jan 22 2021, 11:41:28) [GCC 8.4.1 20200928 (Red Hat 8.4.1-1)]
  jinja version = 2.10.3
  libyaml = True
```


### Configuration

```console
$ ansible-config dump --only-changed
$

(nothing)
```


### OS / Environment

$ cat /etc/redhat-release 
Red Hat Enterprise Linux release 8.4 (Ootpa)


### Steps to Reproduce

### pattern 1:  using `add_host` module 

```
---
- hosts: localhost
  gather_facts: false
  vars:
    test: 1
  tasks:
     - add_host:
         name: "myhost"
         groups: "mygroup"
         ansible_host: "host46"
         ansible_ssh_host: "192.168.100.100"
       failed_when: test == 2
```

When I ran the above playbook, it failed with error as below even the variable 'test' was defined in the play.

```
$ ansible-playbook -i localhost, conditional.yml 

PLAY [localhost] *********************************************************************************************************************************************************************************

TASK [add_host] **********************************************************************************************************************************************************************************
ERROR! The conditional check 'test == 2' failed. The error was: error while evaluating conditional (test == 2): 'test' is undefined
```

If I passed the variable as an extra_vars and specified to be true, it worked as expected.

```
$ ansible-playbook -i localhost, conditional.yml -e "{test: 2}"

PLAY [localhost] *********************************************************************************************************************************************************************************

TASK [add_host] **********************************************************************************************************************************************************************************
fatal: [localhost]: FAILED! => {"add_host": {"groups": ["mygroup"], "host_name": "myhost", "host_vars": {"ansible_host": "host46", "ansible_ssh_host": "192.168.100.100"}}, "changed": false, "failed_when_result": true}

NO MORE HOSTS LEFT *******************************************************************************************************************************************************************************

PLAY RECAP ***************************************************************************************************************************************************************************************
localhost                  : ok=0    changed=0    unreachable=0    failed=1    skipped=0    rescued=0    ignored=0   
```

On the other hand when "{test: 1}", it failed.

```
$ ansible-playbook -i localhost, conditional.yml -e "{test: 1}"

PLAY [localhost] *********************************************************************************************************************************************************************************

TASK [add_host] **********************************************************************************************************************************************************************************
ERROR! The conditional check 'test == 2' failed. The error was: error while evaluating conditional (test == 2): 'test' is undefined
```

### pattern 2: using `debug` module, it worked as desired

```
---
- hosts: localhost
  gather_facts: false
  vars:
    test: 1
  tasks:
     - debug:
         msg: "debug message"
       failed_when: test == 2
```

It works.

```
$ ansible-playbook -i localhost, debug.yml 

PLAY [localhost] *********************************************************************************************************************************************************************************

TASK [debug] *************************************************************************************************************************************************************************************
ok: [localhost] => {
    "msg": "debug message"
}

PLAY RECAP ***************************************************************************************************************************************************************************************
localhost                  : ok=1    changed=0    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0   
```

When passed `2`, it failed as expected.

```
$ ansible-playbook -i localhost, debug.yml -e "{test: 2}"

PLAY [localhost] *********************************************************************************************************************************************************************************

TASK [debug] *************************************************************************************************************************************************************************************
fatal: [localhost]: FAILED! => {
    "msg": "debug message"
}

PLAY RECAP ***************************************************************************************************************************************************************************************
localhost                  : ok=0    changed=0    unreachable=0    failed=1    skipped=0    rescued=0    ignored=0   
```




### Expected Results

The `pattern 1` should work as the `pattern 2` from the point of view of handling the conditional.


### Actual Results

```console
(already pasted above)
```


### Code of Conduct

- [X] I agree to follow the Ansible Code of Conduct
finally:
        termios.tcsetattr(master, termios.TCSANOW, old)
    os.close(master)
    if p.returncode == 0:
        result = json.loads(to_text(stdout, errors='surrogate_then_replace'))
    else:
        try:
            result = json.loads(to_text(stderr, errors='surrogate_then_replace'))
        except getattr(json.decoder, 'JSONDecodeError', ValueError):
            
            result = {'error': to_text(stderr, errors='surrogate_then_replace')}
    if 'messages' in result:
        for level, message in result['messages']:
            if level == 'log':
                display.display(message, log_only=True)
            elif level in ('debug', 'v', 'vv', 'vvv', 'vvvv', 'vvvvv', 'vvvvvv'):
                getattr(display, level)(message, host=play_context.remote_addr)
            else:
                if hasattr(display, level):
                    getattr(display, level)(message)
                else:
                    display.vvvv(message, host=play_context.remote_addr)
    if 'error' in result:
        if play_context.verbosity > 2:
            if result.get('exception'):
                msg = "The full traceback is:\n" + result['exception']
                display.display(msg, color=C.COLOR_ERROR)
        raise AnsibleError(result['error'])
    return result['socket_path']