Skip to content
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 2.0 no longer finds modules in library subdirectories #15432

Closed
mrgnr opened this issue Apr 15, 2016 · 13 comments
Closed

Ansible 2.0 no longer finds modules in library subdirectories #15432

mrgnr opened this issue Apr 15, 2016 · 13 comments
Labels
affects_2.0 This issue/PR affects Ansible v2.0 bug This issue/PR relates to a bug.

Comments

@mrgnr
Copy link
Contributor

mrgnr commented Apr 15, 2016

ISSUE TYPE
  • Bug Report
ANSIBLE VERSION
ansible 2.0.1.0
  config file =
  configured module search path = Default w/o overrides
CONFIGURATION

N/A

OS / ENVIRONMENT

N/A

SUMMARY

I'm upgrading from 1.9.1 to 2.0.1 and Ansible can no longer find modules contained in subdirectories of the library directory. Only modules at the top level of library are found. With Ansible <2.0, modules could be placed in subdirectories. This makes it difficult to use git submodules to add third-party modules to the library.

STEPS TO REPRODUCE
  1. Create directories library/my_module/ alongside a playbook
  2. Create a custom module called my_module and place it in library/my_module
  3. Call my_module from a playbook
  4. Run ansible-playbook
EXPECTED RESULTS

ansible-playbook should find the custom module when run.

ACTUAL RESULTS

ansible-playbook fails with the error ERROR! no action detected in task. This often indicates a misspelled module name, or incorrect module path.

@arikgam
Copy link

arikgam commented Apr 17, 2016

I think this happens to me as well, when using the yumrepo module.
My ansible is on tag v2.0.1.0-1 (bb6cade)

The weird thing is - it works fine on my workstation (Fedora 23, Python 2.7.11-3.fc23, Bash 4.3.42) but fails with this error on our server (CentOS 7, Python 2.7.5-34.el7, Bash 4.2.46).

@bcoca bcoca added the needs_info This issue requires further information. Please answer any outstanding questions. label Apr 25, 2016
@bcoca
Copy link
Member

bcoca commented Apr 25, 2016

afaik its only been supported to have modules/plugins in custom library/ or <plugin_name>_plugins/ dir and not subdirs.

@mrgnr
Copy link
Contributor Author

mrgnr commented Apr 28, 2016

@bcoca The use case here is to pull in third-party modules as git submodules by linking to them in the library/ directory. I imagine this is a fairly common use case, and it worked fine in v1.9.

@relaxdiego
Copy link
Contributor

Ansible docs also state that this subdirectory is auto-loaded: http://docs.ansible.com/ansible/playbooks_best_practices.html#bundling-ansible-modules-with-playbooks

@bcoca
Copy link
Member

bcoca commented Jun 3, 2016

that only points to ./library not sub directories of it.

@dazwin
Copy link

dazwin commented Jun 17, 2016

+1 Whether this was in documentation or not, it was very useful behavior in 1.9. Per @mrgnr, I have also being using git submodules and it worked well - several modules can be installed to the local ansible directory structure and they 'just worked'.

With the current behavior, getting custom modules integrated into an ansible structure becomes a PITA as all custom modules would now have to exist in a single directory (./library). Presumably we'd need to clone the module into a separate directory and run some kind of installation script to copy over the module's source file.

@dazwin
Copy link

dazwin commented Sep 7, 2016

@bcoca - is there any additional information you need to keep this issue alive? Will you accept a PR?

@jctanner
Copy link
Contributor

jctanner commented Sep 7, 2016

!needs_info

@ansibot ansibot added affects_2.0 This issue/PR affects Ansible v2.0 and removed needs_info This issue requires further information. Please answer any outstanding questions. labels Sep 7, 2016
@jctanner
Copy link
Contributor

jctanner commented Dec 1, 2016

I've added this to our core team meeting agenda to get a group decision.

@abadger
Copy link
Contributor

abadger commented Dec 1, 2016

As a workaround, ANSIBLE_LIBRARY can take multiple paths (colon separated just like the PATH environment variable) so you can set each subdirectory as a path as well. I know this still requires two steps but it should be a little easier than moving the module out of the subdirectory to the toplevel ANSIBLE_LIBRARY every time it is updated.

@abadger
Copy link
Contributor

abadger commented Feb 1, 2017

Documentation for using the library configuration var to address this use case is in the following PR: #20913

abadger added a commit to abadger/ansible that referenced this issue Feb 1, 2017
* Add it to the sample ansible.cfg
* Add it to intro_configuration.
* Also modify intro_configuration to place envvars on equal footing with
  the config options (will need to document the envvar names in the
  future)
* Also add the ANSIBLE_LIBRARY use case from
  ansible#15432 so we can close out
  that bug.
abadger added a commit that referenced this issue Feb 3, 2017
* Make the module_utils path configurable
* Add a config value to define the path site module_utils files
* Handle module_utils that do not have source as an error
* Make an integration test for module_utils envvar working
* Add documentation for the ANSIBLE_MODULE_UTILS config option/envvar
* Add it to the sample ansible.cfg
* Add it to intro_configuration.
* Also modify intro_configuration to place envvars on equal footing with
  the config options (will need to document the envvar names in the
  future)
* Also add the ANSIBLE_LIBRARY use case from
  #15432 so we can close out
  that bug.
@abadger
Copy link
Contributor

abadger commented Feb 3, 2017

PR with documentation has been merged to devel. Closing this ticket.

@ansible ansible locked and limited conversation to collaborators Apr 25, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
affects_2.0 This issue/PR affects Ansible v2.0 bug This issue/PR relates to a bug.
Projects
None yet
Development

No branches or pull requests

9 participants