### Summary

Our CI is breaking when gathering facts:
```
TASK [Gathering Facts] *********************************************************
  fatal: [debian-11]: FAILED! => {
      "ansible_facts": {},
      "changed": false,
      "failed_modules": {
          "ansible.legacy.setup": {
              "failed": true,
              "module_stderr": "Error: No such container: inventory_hostname\n",
              "module_stdout": "",
              "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error",
              "rc": 1
          }
      }
  }
  
  MSG:
  
  The following modules failed to execute: ansible.legacy.setup
  ```
https://github.com/pulp/pulp_installer/runs/5134587244?check_suite_focus=true#step:7:147

it believe it started with this commit: https://github.com/ansible/ansible/commit/6d2d476113b3a26e46c9917e213f09494fbc0a13 

### Issue Type

Bug Report

### Component Name

ansible.legacy.setup

### Ansible Version

```console
$ ansible --version
ansible [core 2.13.0.dev0]
  config file = /home/runner/work/pulp_installer/pulp_installer/ansible.cfg
  configured module search path = ['/home/runner/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /opt/hostedtoolcache/Python/3.9.10/x64/lib/python3.9/site-packages/ansible
  ansible collection location = /home/runner/.ansible/collections:/usr/share/ansible/collections
  executable location = /opt/hostedtoolcache/Python/3.9.10/x64/bin/ansible
  python version = 3.9.10 (main, Feb  3 2022, 07:33:39) [GCC 9.3.0]
  jinja version = 3.0.3
  libyaml = True
```


### Configuration

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


### OS / Environment

Debian 11, CentOS 8 stream, fedora 35, CentOS 7

### Steps to Reproduce

Run molecule test with docker images on ansible core 2.13.0.dev0


### Expected Results

Successfully gather facts

### Actual Results

```console
TASK [Gathering Facts] *********************************************************
  fatal: [debian-11]: FAILED! => {
      "ansible_facts": {},
      "changed": false,
      "failed_modules": {
          "ansible.legacy.setup": {
              "failed": true,
              "module_stderr": "Error: No such container: inventory_hostname\n",
              "module_stdout": "",
              "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error",
              "rc": 1
          }
      }
  }
  
  MSG:
  
  The following modules failed to execute: ansible.legacy.setup
  ```


### Code of Conduct

- [X] I agree to follow the Ansible Code of Conduct
'''
        Adds 'magic' variables relating to connections to the variable dictionary provided.
        In case users need to access from the play, this is a legacy from runner.
        '''
        for prop, var_list in C.MAGIC_VARIABLE_MAPPING.items():
            try:
                if 'become' in prop:
                    continue
                var_val = getattr(self, prop)
                for var_opt in var_list:
                    if var_opt not in variables and var_val is not None:
                        variables[var_opt] = var_val
            except AttributeError:
                continue
    def _get_attr_connection(self):
        ''' connections are special, this takes care of responding correctly '''
        conn_type = None
        if self._attributes['connection'] == 'smart':
            conn_type = 'ssh'
            
            if not check_for_controlpersist('ssh') and paramiko is not None:
                conn_type = "paramiko"
        
        elif self._attributes['connection'] == 'persistent' and paramiko is not None:
            conn_type = 'paramiko'
        if conn_type:
            self.connection = conn_type
        return self._attributes['connection']