##### SUMMARY
`[WARNING]: Could not match supplied host pattern, ignoring: <group_name>` is printed prior to the first play for a non-empty group when using a combination of group_by and import_role/import_tasks/include_tasks. Using include_role however works correctly (no warning is displayed).

##### ISSUE TYPE
- Bug Report

##### COMPONENT NAME
ansible-playbook

##### ANSIBLE VERSION
<!--- Paste verbatim output from "ansible --version" between quotes -->
```
ansible 2.9.4
  config file = /etc/ansible/ansible.cfg
  configured module search path = ['/home/vrevelas/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /home/vrevelas/ansible-warning-bug/venv/lib/python3.6/site-packages/ansible
  executable location = /home/vrevelas/ansible-warning-bug/venv/bin/ansible
  python version = 3.6.9 (default, Nov  7 2019, 10:44:02) [GCC 8.3.0]
```

##### CONFIGURATION
<!--- Paste verbatim output from "ansible-config dump --only-changed" between quotes -->
```
```

##### OS / ENVIRONMENT
Ubuntu 18.04 / Python 3.6.9

Note that this behaviour is not reproducible when using the same version of Ansible (2.9.4) and Python 2.7 as opposed to Python 3.

##### STEPS TO REPRODUCE
test.yml
```yaml
---
- hosts: localhost
  tasks:
    - name: Group
      group_by:
        key: test_{{ inventory_hostname }}

- hosts: test_localhost
  tasks:
    - name: Print
      import_tasks: test-tasks.yml
      # the below also trigger the warning - but note that it is not issued when include_role is used:
      # include_tasks: test-tasks.yml
      # import_role:
      #   name: test
```
test-tasks.yml
```yaml
- name: test
  debug:
    msg: hello
```
inventory
```
localhost
```

##### EXPECTED RESULTS
No warning should be printed at the beginning of the output. Replacing `import_tasks` with an `include_role` produces the expected result (no warning).

##### ACTUAL RESULTS
A false-positive warning is printed at the beginning of the output.

Note that the same version of Ansible (2.9.4) installed and run under Python 2.7.17 does not print the false positive warning.
```
ansible-playbook -i inventory test.yml
[WARNING]: Could not match supplied host pattern, ignoring: test_localhost


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

TASK [Gathering Facts] **********************************************************************************
ok: [localhost]

TASK [Group] ********************************************************************************************
ok: [localhost]

PLAY [test_localhost] ***********************************************************************************

TASK [Gathering Facts] **********************************************************************************
ok: [localhost]

TASK [test] *********************************************************************************************
ok: [localhost] => {
    "msg": "hello"
}

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

#
#
#
#
from __future__ import (absolute_import, division, print_function)
__metaclass__ = type
from ansible import constants as C
from ansible import context
from ansible.errors import AnsibleParserError, AnsibleAssertionError
from ansible.module_utils._text import to_native
from ansible.module_utils.six import string_types
from ansible.playbook.attribute import FieldAttribute
from ansible.playbook.base import Base
from ansible.playbook.block import Block
from ansible.playbook.collectionsearch import CollectionSearch
from ansible.playbook.helpers import load_list_of_blocks, load_list_of_roles
from ansible.playbook.role import Role
from ansible.playbook.taggable import Taggable
from ansible.vars.manager import preprocess_vars
from ansible.utils.display import Display
display = Display()
__all__ = ['Play']
class Play(Base, Taggable, CollectionSearch):
    """
    A play is a language feature that represents a list of roles and/or