-
Notifications
You must be signed in to change notification settings - Fork 591
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
"python" command to invoke modules directly does not work with "plugins" directory structure #2374
Comments
Files identified in the description: None If these files are incorrect, please update the |
Thanks for your Ansible docs contribution! We talk about Ansible documentation on Matrix at #docs:ansible.im if you ever want to join us and chat about the docs! We meet on Matrix every Tuesday. See the Ansible calendar for meeting details. We welcome additions to our weekly agenda items too. You can add the |
@sivel @felixfontein - we chatted abit about this issue in the DaWGs meeting and just wanted your nickel that this is a docs problem and not some underlying possible code issue? |
Not a code issue. We probably need more explicit info about the following if there is any hope to address it:
I'm assuming this is due to not using the fwiw, I've always been against the recommendation of directly invoking modules with My 2c is instructions for |
Example with the following cwd structure:
$ ansible localhost -m foo.bar.baz --playbook-dir=$PWD
localhost | SUCCESS => {
"baz": "qux",
"changed": false
} $ PYTHONPATH=./collections/ python -m ansible_collections.foo.bar.plugins.modules.baz ./args.json
{"baz": "qux", "invocation": {"module_args": {}}} I should note that the original instructions in that doc are more geared towards standalone modules, or contributing a module to core, as opposed to collections. The steps I provided above are collection specific. |
* Updated developer guide for module development to work with collection and PYTHONPATH Fixes: ansible#2374 Signed-off-by: Abhijeet Kasurde <[email protected]>
* Updated developer guide for module development to work with collection and PYTHONPATH Fixes: ansible#2374 Signed-off-by: Abhijeet Kasurde <[email protected]>
Summary
The Ansible documentation at https://docs.ansible.com/ansible/latest/dev_guide/developing_modules_general.html#verifying-your-module-code-locally shows this:
/tmp/args.json
and add the following content:This approach does not work when the collection uses the recommended
plugins
subdirectory structure and the module imports from themodule_utils
directory:File
plugins/module_utils/utils.py
:File
plugins/modules/mod1.py
:The approach shown in the documentation fails for such a module with:
Such a module passes the Ansible sanity test, so it must be valid.
By the way, the documented approach of using
ansible -m ...
("ad-hoc" command) also does not work with theplugins
directory structure.Issue Type
Bug Report
Component Name
documentation
Ansible Version
Configuration
OS / Environment
macOS 14.2.7
Python 3.12.7
Steps to Reproduce
The issue can be demonstrated with the
ibm.ibm_zhmc
collection:Expected Results
The documentation should show an approach for locally invoking modules that works with the recommended
plugins
directory structure.Actual Results
See above
Code of Conduct
The text was updated successfully, but these errors were encountered: