* Fix listing of colleciton plugins with symlinks
| ... | ... |
@@ -550,9 +550,9 @@ def get_collection_name_from_path(path): |
| 550 | 550 |
:param n_path: native-string path to evaluate for collection containment |
| 551 | 551 |
:return: collection name or None |
| 552 | 552 |
""" |
| 553 |
- n_collection_paths = [to_native(os.path.realpath(to_bytes(p))) for p in AnsibleCollectionLoader().n_collection_paths] |
|
| 553 |
+ n_collection_paths = [to_native(os.path.abspath(to_bytes(p))) for p in AnsibleCollectionLoader().n_collection_paths] |
|
| 554 | 554 |
|
| 555 |
- b_path = os.path.realpath(to_bytes(path)) |
|
| 555 |
+ b_path = os.path.abspath(to_bytes(path)) |
|
| 556 | 556 |
n_path = to_native(b_path) |
| 557 | 557 |
|
| 558 | 558 |
for coll_path in n_collection_paths: |
| ... | ... |
@@ -575,7 +575,7 @@ def get_collection_name_from_path(path): |
| 575 | 575 |
return None |
| 576 | 576 |
|
| 577 | 577 |
# ensure we're using the canonical real path, with the bogus __synthetic__ stripped off |
| 578 |
- b_loaded_collection_path = os.path.dirname(os.path.realpath(to_bytes(loaded_collection_path))) |
|
| 578 |
+ b_loaded_collection_path = os.path.dirname(os.path.abspath(to_bytes(loaded_collection_path))) |
|
| 579 | 579 |
|
| 580 | 580 |
# if the collection path prefix matches the path prefix we were passed, it's the same collection that's loaded |
| 581 | 581 |
if os.path.commonprefix([b_path, b_loaded_collection_path]) == b_loaded_collection_path: |
| ... | ... |
@@ -9,7 +9,7 @@ export ANSIBLE_HOST_PATTERN_MISMATCH=error |
| 9 | 9 |
|
| 10 | 10 |
|
| 11 | 11 |
# FUTURE: just use INVENTORY_PATH as-is once ansible-test sets the right dir |
| 12 |
-ipath=../../$(basename "${INVENTORY_PATH}")
|
|
| 12 |
+ipath=../../$(basename "${INVENTORY_PATH:-../../inventory}")
|
|
| 13 | 13 |
export INVENTORY_PATH="$ipath" |
| 14 | 14 |
|
| 15 | 15 |
# test callback |
| ... | ... |
@@ -17,6 +17,11 @@ ANSIBLE_CALLBACK_WHITELIST=testns.testcoll.usercallback ansible localhost -m pin |
| 17 | 17 |
|
| 18 | 18 |
# test documentation |
| 19 | 19 |
ansible-doc testns.testcoll.testmodule -vvv | grep -- "- normal_doc_frag" |
| 20 |
+# same with symlink |
|
| 21 |
+ln -s "${PWD}/testcoll2" ./collection_root_sys/ansible_collections/testns/testcoll2
|
|
| 22 |
+ansible-doc testns.testcoll2.testmodule2 -vvv | grep "Test module" |
|
| 23 |
+# now test we can list with symlink |
|
| 24 |
+ansible-doc -l -vvv| grep "testns.testcoll2.testmodule2" |
|
| 20 | 25 |
|
| 21 | 26 |
# test adhoc default collection resolution (use unqualified collection module with playbook dir under its collection) |
| 22 | 27 |
echo "testing adhoc default collection support with explicit playbook dir" |
| 24 | 29 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,33 @@ |
| 0 |
+#!/usr/bin/python |
|
| 1 |
+from __future__ import (absolute_import, division, print_function) |
|
| 2 |
+__metaclass__ = type |
|
| 3 |
+ |
|
| 4 |
+ANSIBLE_METADATA = {'metadata_version': '1.1',
|
|
| 5 |
+ 'status': ['stableinterface'], |
|
| 6 |
+ 'supported_by': 'core'} |
|
| 7 |
+ |
|
| 8 |
+DOCUMENTATION = ''' |
|
| 9 |
+--- |
|
| 10 |
+module: testmodule2 |
|
| 11 |
+short_description: Test module |
|
| 12 |
+description: |
|
| 13 |
+ - Test module |
|
| 14 |
+author: |
|
| 15 |
+ - Ansible Core Team |
|
| 16 |
+''' |
|
| 17 |
+ |
|
| 18 |
+EXAMPLES = ''' |
|
| 19 |
+''' |
|
| 20 |
+ |
|
| 21 |
+RETURN = ''' |
|
| 22 |
+''' |
|
| 23 |
+ |
|
| 24 |
+import json |
|
| 25 |
+ |
|
| 26 |
+ |
|
| 27 |
+def main(): |
|
| 28 |
+ print(json.dumps(dict(changed=False, source='sys'))) |
|
| 29 |
+ |
|
| 30 |
+ |
|
| 31 |
+if __name__ == '__main__': |
|
| 32 |
+ main() |