Repository: ansible/molecule

Issue:
Collection resources not autodetected in v3.5.x
<!--- Verify first that your issue is not already reported on GitHub -->
<!--- Do not report bugs before reproducing them with the code of the main branch! -->
<!--- Please also check https://molecule.readthedocs.io/en/latest/faq.html --->
<!--- Please use https://groups.google.com/forum/#!forum/molecule-users for usage questions -->

# Issue Type

Custom resources installed from a collection during the molecule run are not detected anymore in 3.5.x; the same setup works in v3.4.x 

Collection is successfully installed:

```
Downloading https://gitea.rknet.org/ansible/xoxys.general/releases/download/v2.1.1/xoxys-general-2.1.1.tar.gz to ~/.ansible/tmp/ansible-local-286064kpbiuuus/tmpt5xycanp/xoxys-general-2.1.1-oak5owje
Starting galaxy collection install process
Process install dependency map
Starting collection install process
Installing 'xoxys.general:2.1.1' to '~/.cache/molecule/xoxys.iptables/default/collections/ansible_collections/xoxys/general'
xoxys.general:2.1.1 was installed successfully
INFO     Dependency completed successfully.
```
Example error:

```
TASK [xoxys.iptables : include_tasks] ******************************************
fatal: [centos7-iptables]: FAILED! => {"reason": "couldn't resolve module/action 'iptables_raw'. This often indicates a misspelling, missing collection, or incorrect module path.
```

Downgrading to v3.4.x works

# Molecule and Ansible details

```
ansible [core 2.11.3] 
  config file = None
  configured module search path = ['~/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = ~/.local/pipx/venvs/ansible/lib64/python3.9/site-packages/ansible
  ansible collection location = ~/.ansible/collections:/usr/share/ansible/collections
  executable location = ~/.local/bin/ansible
  python version = 3.9.7 (default, Aug 30 2021, 00:00:00) [GCC 11.2.1 20210728 (Red Hat 11.2.1-1)]
  jinja version = 3.0.1
  libyaml = True
molecule 3.5.1 using python 3.9 
    ansible:2.11.3
    delegated:3.5.1 from molecule
```

Molecule installation method (one of):

- pip

Ansible installation method (one of):

- pip



Discussion:
I think I'm getting the same/similar error. 

Haven't verified it but I think its to do with this line being removed: https://github.com/ansible-community/molecule/pull/3190/files#diff-32abfdacc4eeea878460d3bf0ae452ab074ca485bab0b0a01b3bb07775ac002dL460
Getting the same problem with a collection of roles installed via dependency.options.requirements-file
Troubleshooting :
Behavior in molecule 3.5

- In prerun & lint steps: 
> INFO added ANSIBLE_COLLECTIONS_PATH in prerun and lint steps

- In prepare & converge steps :
> the role xxx was not found in ... (default roles path) => It isn't looking for roles in collections path

Behavior in molecule 3.4 : no logs regarding ANSIBLE_COLLECTIONS_PATH but it works

Tested on MacOS, and GitHub actions (ubuntu), installed via pip with python 3.9.7

Steps to reproduce : 
```bash
git clone https://github.com/klusters/ansible-tls-klusters.git
cd ansible-tls-klusters
pip install -r inventories/test/docker/requirements/python_requirements.txt
molecule test -s kickstart
```
[Here](https://github.com/oasis-roles/ansible_collection_ceph/actions/runs/1259953271) is an example of a run demonstrating @anisf's problem.
@klj613 - that single line was my issue. I "patched" the file in my venv and boom, my role deps worked.
Just ran into this one today.
@ssbarnea Can we just re-add the mentioned line from https://github.com/ansible-community/molecule/issues/3243#issuecomment-925000055 or what's the plan for this issue?

Resolving patch:
diff --git a/src/molecule/provisioner/ansible.py b/src/molecule/provisioner/ansible.py
--- a/src/molecule/provisioner/ansible.py
+++ b/src/molecule/provisioner/ansible.py
@@ -459,6 +459,7 @@ def default_env(self):
                         *os.environ.get("ANSIBLE_ROLES_PATH", "").split(":"),
                     ]
                 ),
+                self._config.ansible_collections_path: ":".join(collections_path_list),
                 "ANSIBLE_LIBRARY": ":".join(self._get_modules_directories()),
                 "ANSIBLE_FILTER_PLUGINS": ":".join(
                     [


Test patch: