From f8a36d792f92a46ed1dff3378dc3d4b89cad651a Mon Sep 17 00:00:00 2001
From: Thomas Woerner <twoerner@redhat.com>
Date: Wed, 19 May 2021 16:01:32 +0200
Subject: [PATCH] ansible-doc-test: Set ANSIBLE_LIBRARY using module_dir
 internally

ANSIBLE_LIBRARY needs to be set properly for new Ansible version 4.0.0
to make sure that it is able to find the module that is checked.

For every file that needs to be checked, there is a separate ansible-doc
call. ANSIBLE_LIBRARY is set using os.path.dirname on the module_path.
---
 utils/ansible-doc-test | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/utils/ansible-doc-test b/utils/ansible-doc-test
index 167d1e00..1c9095c0 100755
--- a/utils/ansible-doc-test
+++ b/utils/ansible-doc-test
@@ -29,12 +29,16 @@ import subprocess
 
 def run_ansible_doc(role, module, verbose=False):
     playbook_dir, module_path = get_playbook_dir(role, module)
+    module_dir = os.path.dirname(module_path)
 
-    command = ["ansible-doc",
+    command = ["env",
+               "ANSIBLE_LIBRARY=%s" % module_dir,
+               "ansible-doc",
                "--playbook-dir=%s" % playbook_dir,
                "--type=module",
                "-vvv",
                module]
+
     process = subprocess.run(command,
                              stdout=subprocess.PIPE,
                              stderr=subprocess.PIPE)
-- 
GitLab