### 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
play_context = play_context.set_task_and_variable_override(task=task, variables=all_vars, templar=templar)
            
            
            play_context.post_validate(templar=templar)
            
            
            if not play_context.remote_addr:
                play_context.remote_addr = target_host.address
            
            
            play_context.update_vars(all_vars)
            if target_host in self._active_connections:
                connection = Connection(self._active_connections[target_host])
                del self._active_connections[target_host]
            else:
                connection = plugin_loader.connection_loader.get(play_context.connection, play_context, os.devnull)
                connection.set_options(task_keys=task.dump_attrs(), var_options=all_vars)
                play_context.set_attributes_from_plugin(connection)
            if connection:
                try:
                    connection.reset()
                    msg = 'reset connection'
                except ConnectionError as e:
                    
                    display.debug("got an error while closing persistent connection: %s" % e)
            else:
                msg = 'no connection, nothing to reset'
        else:
            raise AnsibleError("invalid meta action requested: %s" % meta_action, obj=task._ds)