Repository navigation
Fix wrong environment variables being passed to ansible compat (#3404) - #3516
Conversation
for more information, see https://pre-commit.ci
|
I am wondering how were you able to run these commands considering that latest version of ansible-lint removed both "core" and "yamllint" extras, so pip install with them would fail. Are you sure you used py38 or newer? |
Thank you for asking. I tested this with my companies internal galaxy roles, and it worked there. We host them in individual private git repos, and this bug hit us pretty hard when molecule stopped working with requirements.yml. The versions of software that were tested are as follows: The Jenkins server we use to run the molecule testing uses python 3.8, and this worked with ansible stable 2.12.3. To be sure I had a clean environment, I deleted the python3 -m venv .venv; source .venv/bin/activate
pip install --upgrade pip wheel; pip install --upgrade 'ansible-lint[core,yamllint]' 'molecule[docker,lint]'
pip install --upgrade \
git+https://github.com/marblenix/molecule@main \
git+https://github.com/ansible/ansible-compat@main \
git+https://github.com/ansible/ansible@develYou can see the final requirements.txt I tested with here: https://github.com/marblenix/molecule-bug-demo-3404/blob/main/requirements.txt I hope that answers your question. |
|
Lets hope I will not have to yank that fix. |
|
This PR is actually regressing things (at least molecule-vagrant CI). From the logs, I can see: vs (https://github.com/ansible-community/molecule-vagrant/runs/6122171777?check_suite_focus=true) Which means that the path to the molecule-vagrant module is lost, leading to the failures. I've yet to find time to try finding a fix. |
|
This fix broke syntax check step for me. I think ANSIBLE_ROLES_PATH is now calculated incorrectly, but I'm not really sure why. Here are the logs (roles being tested were not modified between runs):
Correct roles directory ( |
|
Uhm, if I understand this PR correctly, when a key exists both in I'm not sure why such order of priority has been chosen. It seems to me that it should be the other way around (or maybe an even more complex merging logic is required) since a lot of Molecule code is touching @marblenix, can you elaborate on why your suggested order of priority should be used? |
|
Sure, the order was chosen because I assumed that the values in runtime were more important. As I was debugging and stepping through the code I did see that molecule focused on provisioner changes, but I noticed ansible-compat cared a lot about what values were set. I picked the order because I thought it'd be the safest route to keep the compat library happy. |
|
I disagree. As I see it, the edits done by Molecule are there for a reason and it's not ok to just drop them. Broken builds reported by two people (myself included) support my intuition. But I'm hardly an expert here. @ssbarnea, what do you think? |
|
I tested the changes I made on all of our companies projects, but if there are reported broken builds, that's definitely my fault for this assumption. I'll make a PR to switch the order today. |
|
Can't we merge variable instead of overwriting things ? |
|
Hi @marblenix
If the issue is Could you please consider the following PRs?
|
You can find a demo of this error here:
https://github.com/marblenix/molecule-bug-demo-3404/commits/main
In the body of each commit, details the commands that are needed to be run to reproduce the error with minimal setup, with the last one pushing a requirements.txt file to this branch. To see the error, it's recommended to be working on a machine that hasn't had
ansible-galaxy collection installrun on it before. If you are unable to reproduce the issue locally, try removing the cached roles and collections folders.To test my changes, run:
I ran the test suite by enabling actions on my fork. The tox parts failed when it needed the secrets, but the unit tests themselves still passed. https://github.com/marblenix/molecule/actions/runs/2193046395
Please note, this will not solve the issue with #3513. It does allow for a workaround to this bug by adding the following to a requirements.yml file:
--
The exact cause of this issue is this line here in ansible-compat: https://github.com/ansible/ansible-compat/blob/05d94d4d1b484b05c53c9b5844e4187d9872c258/src/ansible_compat/runtime.py#L515
The problem is ansible-compat is adding these environment variables to the runtime, and molecule is adding its own variables to the provisioner. Combining them seems to resolve the issue just fine.
To verify that this specific problem is resolved, run tests like so:
molecule --debug -v test. The very last output ofDEBUG: SHELL REPLAY:should include a line about ANSIBLE_COLLECTIONS_PATH being in~/.cache/ansible-compat/DEADBEEF/collections:...