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
Correctly handle ANSIBLE_FILTER_PLUGINS for plugin vendored filter functions #31
Comments
Hi @tumbl3w33d! Thanks for taking some time on this one.
💯 will happily merge a PR for this 💯
This sounds like a bug. @ggggut do you have any idea why that might be happening (from #29). I'll note that this doesn't happen in the test suites so I am wondering if this is something in your local setup @tumbl3w33d but I can't be quite sure what. I don't have much time this week but I'll try to look into this shortly. If you have any fix suggestions, let me know! |
Thank you for your fast reply. I'll try to gather some more in-depth information about what causes the filter path issue. |
i.e., instead of throwing a red fatal error message at the user and recovering with a rescue block we downgrade the lookup error to a warning and set the same defaults in that case that were set in the rescue block before. See #31.
I reproduced it in a fresh folder with a fresh role: # created a new directory 'foo' and stepped into it
# then we create a virtualenv
[myuser@myworkstation foo]$ python3 -m venv venv
# and activate it
[myuser@myworkstation foo]$ . venv/bin/activate
# we install the modules ansible, molecule[hetznercloud] and molecule-hetznercloud
(venv) [myuser@myworkstation foo]$ pip install -r requirements.txt
[…]
# we create a fresh role
(venv) [myuser@myworkstation foo]$ molecule init role foo -d hetznercloud
INFO Initializing new role foo...
No config file found; using defaults
- Role foo was created successfully
INFO Initialized role in /home/myuser/projects/foo/foo successfully. Then I prepared the run:
Not sure yet if I did something wrong at some point, but the path of the virtualenv is different from where molecule is searching. |
Hello, coworker of @ggggut here. I can reproduce this in a virtualenv. |
Hey @ekeih, thanks for looking into this! So, we need to pass our own From the good investigation of @tumbl3w33d it looks like we instead need to hook into the We can hook into that in our own subclass here in this plugin over at:
We need to get something like Does anyone have energy/time for a PR for this? |
I saw that an active virtualenv comes with an env var that we can rely on to build the path:
Not sure how to handle the moving python version, though. Edit: |
By removing the duplicated code in the cookiecutter template the playbooks of the installed driver are used. Those are then able to find the filter_plugin, which relates ansible-community#31.
Thanks for the additional insights @decentral1se :) I understand that we need our own I created #33 to better show what I mean. If I use the code from this branch everything works as expected. Maybe you can try the branch and check if it also works for you or if I am missing a scenario where the templated copy of the playbooks is required. |
I've just started using this and was confused by some errors the generated default files emit.
The first one was as edge case that I, unfortunately, cannot reproduce anymore right now. It wouldn't hurt to handle it gracefully anyway, I guess
It's not a big deal after all, because this happens in a rescue block, but it confused me at first until I found that out. I'd suggest to add a
failed_when
that catches this expected condition. Something like:A second thing that caused problems was the generated
create.yml
as it uses the filtermolecule_get_hetznercloud_networks
that are not in thefilter_path
and there's no explanation in the documentation how to fix that.I could try pointing that to the virtualenv path but it's not really stable as the python version changes. When you rename/delete the
create.yml
then the "implicit" one is executed and it finds its filter. Copying this filter to the role does not seem like a maintainable solution to me either.The text was updated successfully, but these errors were encountered: