From 30db047b0a3e2cb0061196dbe801f7b63f1f0889 Mon Sep 17 00:00:00 2001 From: Thomas Woerner Date: Wed, 19 May 2021 11:39:44 +0200 Subject: [PATCH 1/4] .pre-commit-config.yaml: Do not set ANSIBLE_LIBRARY for ansible-doc-test With latest Ansible (4.0.0) it is needed to have a complete path for ANSIBLE_LIBRARY. It is not good to hard code this in the .pre-commit-config.yaml file for plugins and also all roles. Instead it will be set in ansible-doc-test as it knows the path for each file that is checked. --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 671356af..ec90f12a 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -26,6 +26,6 @@ repos: - id: ansible-doc-test name: Verify Ansible roles and module documentation. language: python - entry: env ANSIBLE_LIBRARY=./plugins/modules utils/ansible-doc-test + entry: utils/ansible-doc-test # args: ['-v', 'roles', 'plugins'] files: ^.*.py$ From 86ec69b8c28cf130f550b92403f97d6b1752e342 Mon Sep 17 00:00:00 2001 From: Thomas Woerner Date: Wed, 19 May 2021 16:29:42 +0200 Subject: [PATCH 2/4] .github/workflows/docs.yml: Enable verbose mode for ansible-doc-test Currently ansible-doc-test is run silently. There is no output about the checked files in the test results. Therefore verbose mode has been enabled. --- .github/workflows/docs.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index 2b7f782e..f2f7c8a1 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -28,5 +28,5 @@ jobs: - name: Run ansible-doc-test run: | python -m pip install ansible - ANSIBLE_LIBRARY="." python utils/ansible-doc-test roles plugins + ANSIBLE_LIBRARY="." python utils/ansible-doc-test -v roles plugins From f8a36d792f92a46ed1dff3378dc3d4b89cad651a Mon Sep 17 00:00:00 2001 From: Thomas Woerner Date: Wed, 19 May 2021 16:01:32 +0200 Subject: [PATCH 3/4] 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) From a07005778698e112f85d0d849cc336353bbe95ec Mon Sep 17 00:00:00 2001 From: Thomas Woerner Date: Wed, 19 May 2021 16:29:42 +0200 Subject: [PATCH 4/4] .github/workflows/docs.yml: Enable verbose mode for ansible-doc-test Currently ansible-doc-test is run silently. There is no output about the checked files in the test results. Therefore verbose mode has been enabled. --- .github/workflows/docs.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index f2f7c8a1..6212cfa4 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -15,7 +15,7 @@ jobs: - name: Run ansible-doc-test run: | python -m pip install "ansible < 2.10" - ANSIBLE_LIBRARY="." python utils/ansible-doc-test roles plugins + ANSIBLE_LIBRARY="." python utils/ansible-doc-test -v roles plugins check_docs_latest: name: Check Ansible Documentation with latest Ansible.