-
Notifications
You must be signed in to change notification settings - Fork 199
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
Support for ansible collections import hook #652
Comments
Hi Jacob! For collections they have implemented a Python import hook. Mitogen needs a little massaging to work for it. I'm busy on another project just now but will come to this real soon, it's a fairly straightforward fix Thanks for reporting, and apologies for the huge delay |
When I took the traceback screenshot, I picked the portion that shows Ansible's PEP 451 import loader for collections. I figured it was a conflict in how that import loader and the mitogen import system worked. Do you need any more details to diagnose this? |
Oh, and no problem on the delay. I have been quite swamped as well! That said, I am very much looking forward to speeding up a playbook using mitogen. It is in a collection and the entire playbook runs with |
I get the same error using mitogen 0.2.9 and ansible 2.9.0, it also occurs without Output:
|
@dw any luck with supporting the collections import hook? |
So would the import hook need to be addressed here? Would the module loader and other plugin type leaders also need to be wrapped? Collections can include any type of plugin (afaik - there may be a few exceptions but I'm not sure). I see an import hook here, would that need to be adjusted? I'm also looking at the Can this be addressed directly in |
@s1113950 You said you're looking at adding support for Ansible 2.9 in #323. I'd love to use mitogen, but I depend on collections support so I haven't been able to test any of my playbooks with mitogen yet. |
Sure yeah I can take a look :) |
Sure, I'll look up the PRs, get a sample playbook, and post some additional background on collections later today. :) thank you edit: add todo list
|
FYI: A lot of work for developing collections actually happened in (an)other repo(s). So if you're looking for older info, you'll want to search for "mazer" which was a fork of the |
The plan is to move most modules/plugins (esp community maintained modules and network device plugins) out of ansible. Instead of batteries included, you will need to use various content collections that have their own release schedule separate from ansible itself. FQCN = Fully Qualified Collection Name Background
Official docsThese link to devel version as most up-to-date. Some of this used to be in the ansible-galaxy docs, but since 2.8 they've been moving to docs for ansible itself In Ansible's CodePrimary parts of ansible core code:
Ansible code changes:
Collection ContentsCollections can contain roles, modules, actions, and many (in 2.10 all) other plugin types. Playbooks can be included in collections, but the clean support for auto finding them without an absolute path is not baked into ansible yet. target host-side plugin types that mitogen will probably need to handle in collections:
All controller-side plugin types can be in a collection with a few caveats (not sure which of these mitogen needs to handle or integrate with):
The draft collection shows the layout of a collection with dirs for a lot of plugin types. |
Here's a simple playbook + collection where the collection includes roles and a module: |
Here's a collection (for debugging collections lol) that has several kinds of plugins:
|
@cognifloyd thanks for all the info! |
@cognifloyd I'm probably doing something wrong 🤔 This is with ansible 2.8.8. The link you posted https://galaxy.ansible.com/alikins/collection_inspect said that it's only supported in ansible 2.9+ but you mentioned it was also backported to 2.8.3 so I thought it would work with 2.8.8 as well? How do I install a collection in 2.8? |
Or is it better to just get it to work in 2.9? |
doh. I forgot about that. Yeah, skip 2.8 for now since we can't really install collections with it. |
So, I guess that means get everything else working with 2.9 before tackling collections? |
Makes sense to me yeah 👍 |
Gonna try collections now |
@cognifloyd I found something interesting: I didn't get the
I'm gonna run it from the task-level now and get it working there! |
I don't get the error on the task-level when using: Here's the playbook:
and here's the role:
Previously I got the I moved them to be declared in the playbook, and then had the playbook run the example there and it worked. @cognifloyd is that not how people run collections? 🤔 |
I'll continue trying the other playbooks here: https://github.com/alikins/collection_inspect/tree/master/playbooks |
aHa! Finally able to repro at the task level. Sweet |
currently stuff loads, sorta. Submodules of It has to do with the quite hacky way that collections are assembled (they're effectively a fake module with no real |
Just a hint: the Python loader underwent a significant rewrite for 2.10 in ansible/ansible#67684 - largely to make it more "Python standards-compliant". That said, we purposely don't "Python load" module/module_util code during Ansible module construction, because that causes the Python module global code to execute in the controller (which can have ... interesting side effects, depending on the module). Unfortunately, |
Hi folks, |
Ansible 2.8.4 + mitogen 0.2.8
Collections installed in ~/.ansible/collections
Playbook and all roles are in a collection.
It looks like the mitogen linear_strategy is not compatible with the collections loader.
Sorry I'm working remotely (to test mitogen with this playbook) on my phone so all I can provide are screenshots of the error. I can look up more details next week.
The text was updated successfully, but these errors were encountered: