##### SUMMARY
Example here is AWS account ID, which is clearly an integer-like thing. The keyed_group templating logic will error if it gets a type other than a string... but sometime after Ansible 2.9, it seems that I _can't_ cast it to a string

##### ISSUE TYPE
- Bug Report

##### COMPONENT NAME
lib/ansible/plugins/inventory/__init__.py

##### ANSIBLE VERSION
```
$ ansible --version
[WARNING]: You are running the development version of Ansible. You should only run Ansible from "devel" if you are modifying the Ansible engine, or trying out features under
development. This is a rapidly changing source of code and can become unstable at any point.
ansible 2.11.0.dev0
  config file = None
  configured module search path = ['/Users/alancoding/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /Users/alancoding/Documents/repos/ansible/lib/ansible
  ansible collection location = /Users/alancoding/.ansible/collections:/usr/share/ansible/collections
  executable location = /Users/alancoding/.virtualenvs/awx_collection/bin/ansible
  python version = 3.7.7 (default, Mar 10 2020, 15:43:03) [Clang 11.0.0 (clang-1100.0.33.17)]
```

##### CONFIGURATION
Defaults

##### OS / ENVIRONMENT
N/A


##### STEPS TO REPRODUCE
Inventory file `aws_ec2.yml`

```yaml
compose:
  ec2_account_id: owner_id
keyed_groups:
- key: ec2_account_id | string
  parent_group: accounts
  prefix: ''
  separator: ''
plugin: amazon.aws.aws_ec2
```

Command:

```
AWS_ACCESS_KEY_ID=<redacted> AWS_SECRET_ACCESS_KEY=<redacted> ANSIBLE_JINJA2_NATIVE=True ansible-inventory -i testing/awx_424_0bzcwopc/aws_ec2.yml --list --export -vvv
```

##### EXPECTED RESULTS
Behavior in 2.9 is that it gives JSON data for the inventory.

I think it also needs to be stated that input variables look like this:

```           
                         "ec2_account_id": "123456789",
                "owner_id": "123456789",
```


##### ACTUAL RESULTS

```
[WARNING]:  * Failed to parse /Users/alancoding/Documents/tower/testing/awx_424_0bzcwopc/aws_ec2.yml with auto plugin: Invalid group name format, expected a string or a list
of them or dictionary, got: <class 'int'>
  File "/Users/alancoding/Documents/repos/ansible/lib/ansible/inventory/manager.py", line 289, in parse_source
    plugin.parse(self._inventory, self._loader, source, cache=cache)
  File "/Users/alancoding/Documents/repos/ansible/lib/ansible/plugins/inventory/auto.py", line 58, in parse
    plugin.parse(inventory, loader, path, cache=cache)
  File "/Users/alancoding/.ansible/collections/ansible_collections/amazon/aws/plugins/inventory/aws_ec2.py", line 644, in parse
    self._populate(results, hostnames)
  File "/Users/alancoding/.ansible/collections/ansible_collections/amazon/aws/plugins/inventory/aws_ec2.py", line 534, in _populate
    self._add_hosts(hosts=groups[group], group=group, hostnames=hostnames)
  File "/Users/alancoding/.ansible/collections/ansible_collections/amazon/aws/plugins/inventory/aws_ec2.py", line 569, in _add_hosts
    self._add_host_to_keyed_groups(self.get_option('keyed_groups'), host, hostname, strict=strict)
  File "/Users/alancoding/Documents/repos/ansible/lib/ansible/plugins/inventory/__init__.py", line 431, in _add_host_to_keyed_groups
    raise AnsibleParserError("Invalid group name format, expected a string or a list of them or dictionary, got: %s" % type(key))
```

No matter what I do, it doesn't seem to use this as a string.

Presumably, this may be something that can be reproduced with the constructed inventory plugin by itself, but I have not gotten that far yet.

So something is forcing this into an integer, and it wasn't there is 2.9. That's about the extent of what I know at this point.

from ansible.template.vars import AnsibleJ2Vars
from ansible.utils.collection_loader import AnsibleCollectionRef
from ansible.utils.display import Display
from ansible.utils.collection_loader._collection_finder import _get_collection_metadata
from ansible.utils.unsafe_proxy import wrap_var
display = Display()
__all__ = ['Templar', 'generate_ansible_template_vars']
NON_TEMPLATED_TYPES = (bool, Number)
JINJA2_OVERRIDE = '#jinja2:'
from jinja2 import __version__ as j2_version
USE_JINJA2_NATIVE = False
if C.DEFAULT_JINJA2_NATIVE:
    try:
        from jinja2.nativetypes import NativeEnvironment as Environment
        from ansible.template.native_helpers import ansible_native_concat as j2_concat
        USE_JINJA2_NATIVE = True
    except ImportError:
        from jinja2 import Environment
        from jinja2.utils import concat as j2_concat
        display.warning(
            'jinja2_native requires Jinja 2.10 and above. '
            'Version detected: %s. Falling back to default.' % j2_version
        )
else:
    from jinja2 import Environment
    from jinja2.utils import concat as j2_concat
JINJA2_BEGIN_TOKENS = frozenset(('variable_begin', 'block_begin', 'comment_begin', 'raw_begin'))
JINJA2_END_TOKENS = frozenset(('variable_end', 'block_end', 'comment_end', 'raw_end'))
RANGE_TYPE = type(range(0))
def generate_ansible_template_vars(path, dest_path=None):