-
Notifications
You must be signed in to change notification settings - Fork 659
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ANSIBLE_ROLES_PATH not set correctly? #3404
Comments
Try the code from main branch and repot the outcome. I am aware of several changes that are likely to affect role paths. |
Tested with main branch. Same result. 3.4.1 is successful. Latest isn't. To summarize the issues from yesterday: |
More info: it looks like these changes first appeared 8 days ago and correspond to the release of ansible-compat 1.0.0, 8 days ago. Before the jobs were using Molecule 3.5.2 and ansible-compat-0.5.0 successfully. |
that is indeed useful. i will try to look at it tomorrow, ping me in irc/matrix if you can and maybe we can debug it and make a hotfix. |
Also it's feasible to replicate the issue pretty quickly by forking these repos and enabling circleci builds:
ansible-compat/issues/114 looks similar. Could be identical. |
This is occurring on https://github.com/artis3n/ansible-role-tailscale as well after updating to ansible 5.x. Reverting the ansible version back while keeping molecule on the latest version resolves the issue. At least, I don't see changes to Molecule in the Pipfile.lock but I may not recognize a sub-dependency conflict or something. The following is the PR I was working on and has the exact Pipfile.lock changes that lead to this molecule error. Note after reverting my Pipfile.lock to the version on From a Codespace: WORKING: @artis3n ➜ /workspaces/ansible-role-tailscale (main) $ pipenv run ansible --version
ansible [core 2.11.6]
config file = None
configured module search path = ['/home/vscode/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /home/vscode/.local/share/virtualenvs/ansible-role-tailscale-tV5cXObL/lib/python3.10/site-packages/ansible
ansible collection location = /home/vscode/.ansible/collections:/usr/share/ansible/collections
executable location = /home/vscode/.local/share/virtualenvs/ansible-role-tailscale-tV5cXObL/bin/ansible
python version = 3.10.0 (default, Nov 17 2021, 15:26:39) [GCC 10.2.1 20210110]
jinja version = 3.0.3
libyaml = True
@artis3n ➜ /workspaces/ansible-role-tailscale (main) $ pipenv run molecule --version
molecule 3.5.2 using python 3.10
ansible:2.11.6
delegated:3.5.2 from molecule
docker:1.1.0 from molecule_docker requiring collections: community.docker>=1.9.1 BROKEN: @artis3n ➜ /workspaces/ansible-role-tailscale (ansible5.x) $ pipenv run ansible --version
ansible [core 2.12.1]
config file = None
configured module search path = ['/home/vscode/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /home/vscode/.local/share/virtualenvs/ansible-role-tailscale-tV5cXObL/lib/python3.10/site-packages/ansible
ansible collection location = /home/vscode/.ansible/collections:/usr/share/ansible/collections
executable location = /home/vscode/.local/share/virtualenvs/ansible-role-tailscale-tV5cXObL/bin/ansible
python version = 3.10.0 (default, Nov 17 2021, 15:26:39) [GCC 10.2.1 20210110]
jinja version = 3.0.3
libyaml = True
@artis3n ➜ /workspaces/ansible-role-tailscale (ansible5.x) $ pipenv run molecule --version
molecule 3.5.2 using python 3.10
ansible:2.12.1
delegated:3.5.2 from molecule
docker:1.1.0 from molecule_docker requiring collections: community.docker>=1.9.1 |
The issue is caused by the changes to the In version 1.0.0, ansible-compat added a parameter to the method, https://github.com/ansible-community/ansible-compat/blob/v1.0.0/src/ansible_compat/runtime.py#L299, called Changing the invocation from If you want, I can test the change and make a pull request. |
Please do. We do have a good test coverage so we should get an idea about the impact of this move. |
This issue is not fully related to merged fix. The main reason is in that molecule doesn't look at the env variables exposed by ansible-compat during prerun. Here is the example of 'ANSIBLE_COLLECTIONS_PATH' and 'ANSIBLE_ROLES_PATH' variables:
|
#3516) * Fix wrong environment variables being passed to ansible compat (#3404) * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1136ea5 (PR #3516) seems to break local install again:
|
Hi @bonddim
Could you help verify whether #3514 and ansible/ansible-compat#135 address your issue? |
Currently, As we all know, Instead, it is in this ansible/ansible-compat#135 that roles or collections would be installed to |
Hi @zhan9san
Those fixes issues with roles, but not collections. |
Hi @bonddim
Could you please give more detailed information about the collections? I verified it through the following commands, and it works as expected Set up a test environmentEnsure docker daemon is available, and then pip install git+https://github.com/zhan9san/molecule@feature/add-cache-dir-into-ansible-roles-path
pip install git+https://github.com/zhan9san/ansible-compat@feature/install-role-in-cache-dir
pip install molecule-docker Create a role$ molecule init role acme.my_new_role --driver-name docker Run test$ cd my_new_role
$ molecule test Verify roles installed$ ll ~/.cache/ansible-compat/b4d3f4/roles
total 0
lrwxr-xr-x 1 jackzhang TNSOFTWARE\Domain Users 32B Apr 28 16:16 acme.my_new_role -> /Users/jackzhang/tmp/my_new_role Define requirementsThe roles and collections in Create a $ cat requirements.yml
---
roles:
# Install a role from Ansible Galaxy.
- name: geerlingguy.java
version: 1.9.6
collections:
# Install a collection from Ansible Galaxy.
- name: geerlingguy.php_roles
version: 0.9.3
source: https://galaxy.ansible.com Verify the roles and collections in
|
You are right. The isolated collections path installed by It may work now. |
@zhan9san During roles test (as you describe), all is ok |
this fixes the issue with collections |
Can you verify whether #3514 address your issue? pip install git+https://github.com/zhan9san/molecule@feature/add-cache-dir-into-ansible-roles-path
pip install ansible-compat==2.1.0 |
#3569 should fix it. |
- ansible/molecule#3404 - ansible/molecule#3569 - ansible/molecule#3514 - https://pypi.org/project/molecule/#history - remove workaround for broken collection support
- ansible/molecule#3404 - ansible/molecule#3569 - ansible/molecule#3514 - https://pypi.org/project/molecule/#history - remove workaround for broken collection support
Issue Type
Molecule and Ansible details
5.1.0 and 3.5.1
Molecule installation method (one of):
Have tried both methods.
Ansible installation method (one of):
pip
Desired Behavior
Molecule tests that have been passing, should continue to be passing. When running in CI, if roles are installed, the ANSIBLE_ROLES_PATH points to the roles.
Actual Behaviour
Running molecule ansible tests in CircleCI.
Certain tests that succeeded one month ago are failing now, even though nothing apparently changed. It's not impossible, that this is being caused by something else entirely such as Ansible itself or another package. However at the moment it looks like molecule so your feedback would be helpful to point in the right direction.
Case 1:
https://app.circleci.com/pipelines/github/cloudalchemy/ansible-prometheus?branch=master&filter=all
When molecule ran on Dec 27, 2021, it succeeded.
Here is a interesting snippet from the log output:
Notice that it's creating a symlink.
Now,
The wording changed from "Added" to "Set". So, something changed. And it does not mention the symlink anymore. Probably no symlink is being created. Because of that the test fails, during "molecule syntax". It can't find the role.
Case 2:
This repo used to succeed, about a month ago.
https://app.circleci.com/pipelines/github/prometheus/demo-site/833/workflows/39439543-5173-4027-8be0-3d1817db7b7c/jobs/3397
Now it's failing:
https://app.circleci.com/pipelines/github/prometheus/demo-site/857/workflows/82accec5-9ae4-4c17-ba50-9c25d35b550e/jobs/3516
When does it fail? During the tests, it gets to this step:
Again, it can't find the roles. Similar to Case 1.
Where are the roles being installed? It can be seen that ansible-galaxy installs roles in /home/circleci/project/roles/
If we test with ansible 5.1 and molecule version 3.4.1, the tests succeed. Here is log output regarding ANSIBLE_ROLES_PATH
Next, test with ansible 5.1 and molecule 3.5.1. This fails.
The wording has changed from "Added" to "Set". Why? And, more importantly, the "Set" did not accomplish anything because it didn't set the path.
The debug information (lines 3 and 4) shows something different from the "Set" (line 1).
The text was updated successfully, but these errors were encountered: