From 13a5f7075cd1d09d444095a65cdb58d8cc9837a9 Mon Sep 17 00:00:00 2001 From: Harsha Cherukuri Date: Tue, 24 Mar 2026 10:49:10 -0400 Subject: [PATCH] Fix ansible-doc errors --- molecule/prod_eap/converge.yml | 72 +++++++++++-------- .../jbossnetwork_connection_options.py | 61 ---------------- plugins/modules/product_download.py | 53 +++++++++++++- plugins/modules/product_search.py | 53 +++++++++++++- 4 files changed, 145 insertions(+), 94 deletions(-) delete mode 100644 plugins/doc_fragments/jbossnetwork_connection_options.py diff --git a/molecule/prod_eap/converge.yml b/molecule/prod_eap/converge.yml index 551cbbf..88ccfcd 100644 --- a/molecule/prod_eap/converge.yml +++ b/molecule/prod_eap/converge.yml @@ -2,35 +2,49 @@ - name: Converge hosts: localhost gather_facts: no + vars: + client_id: "{{ lookup('env', 'PROD_JBOSSNETWORK_API_CLIENTID') }}" + client_secret: "{{ lookup('env', 'PROD_JBOSSNETWORK_API_SECRET') }}" tasks: - - name: Search EAP Product - middleware_automation.common.product_search: - client_id: "{{ lookup('env', 'PROD_JBOSSNETWORK_API_CLIENTID') }}" - client_secret: "{{ lookup('env', 'PROD_JBOSSNETWORK_API_SECRET') }}" - product_type: DISTRIBUTION - product_version: '7.4' - product_category: appplatform - register: rhn_products - no_log: false + - name: Execute scenario when production credentials are provided + when: + - client_id is defined and client_id | length > 0 + - client_secret is defined and client_secret | length > 0 + block: + - name: Search EAP Product + middleware_automation.common.product_search: + client_id: "{{ lookup('env', 'PROD_JBOSSNETWORK_API_CLIENTID') }}" + client_secret: "{{ lookup('env', 'PROD_JBOSSNETWORK_API_SECRET') }}" + product_type: DISTRIBUTION + product_version: '7.4' + product_category: appplatform + register: rhn_products + no_log: false + + - name: Search install zipfile + ansible.builtin.set_fact: + rhn_filtered_products: "{{ rhn_products.results | selectattr('file_path', 'match', '[^/]*/jboss-eap-7.4.0.zip$') }}" + + - name: Retrieve product download using JBossNetwork API + middleware_automation.common.product_search: + client_id: "{{ lookup('env', 'PROD_JBOSSNETWORK_API_CLIENTID') }}" + client_secret: "{{ lookup('env', 'PROD_JBOSSNETWORK_API_SECRET') }}" + product_type: BUGFIX + product_version: '7.4' + product_category: appplatform + register: rhn_products + no_log: true + + - name: Determine patch versions list + ansible.builtin.set_fact: + filtered_versions: "{{ rhn_products.results | map(attribute='file_path') | select('match', '^[^/]*/jboss-eap-.*[0-9]*[.][0-9]*[.][0-9]*.*$') | map('regex_replace','[^/]*/jboss-eap-([0-9]*[.][0-9]*[.][0-9]*)-.*','\\1' ) | list | unique }}" + + - name: Determine latest version + ansible.builtin.debug: + msg: "JBoss EAP 7.4 most recent CP is version {{ filtered_versions | middleware_automation.common.version_sort | last }}" - - name: Search install zipfile - ansible.builtin.set_fact: - rhn_filtered_products: "{{ rhn_products.results | selectattr('file_path', 'match', '[^/]*/jboss-eap-7.4.0.zip$') }}" - - - name: Retrieve product download using JBossNetwork API - middleware_automation.common.product_search: - client_id: "{{ lookup('env', 'PROD_JBOSSNETWORK_API_CLIENTID') }}" - client_secret: "{{ lookup('env', 'PROD_JBOSSNETWORK_API_SECRET') }}" - product_type: BUGFIX - product_version: '7.4' - product_category: appplatform - register: rhn_products - no_log: true - - - name: Determine patch versions list - ansible.builtin.set_fact: - filtered_versions: "{{ rhn_products.results | map(attribute='file_path') | select('match', '^[^/]*/jboss-eap-.*[0-9]*[.][0-9]*[.][0-9]*.*$') | map('regex_replace','[^/]*/jboss-eap-([0-9]*[.][0-9]*[.][0-9]*)-.*','\\1' ) | list | unique }}" - - - name: Determine latest version + - name: Skip message when credentials not provided ansible.builtin.debug: - msg: "JBoss EAP 7.4 most recent CP is version {{ filtered_versions | middleware_automation.common.version_sort | last }}" + msg: "Skipping EAP prod scenario - set PROD_JBOSSNETWORK_API_CLIENTID and PROD_JBOSSNETWORK_API_SECRET to exercise JBoss Network API tests" + when: + - client_id is not defined or client_id | length == 0 or client_secret is not defined or client_secret | length == 0 diff --git a/plugins/doc_fragments/jbossnetwork_connection_options.py b/plugins/doc_fragments/jbossnetwork_connection_options.py deleted file mode 100644 index 0f6d62b..0000000 --- a/plugins/doc_fragments/jbossnetwork_connection_options.py +++ /dev/null @@ -1,61 +0,0 @@ -from __future__ import absolute_import, division, print_function - -__metaclass__ = type - - -class ModuleDocFragment(object): - - DOCUMENTATION = r""" -options: - api_url: - description: - - Address of the JBoss Network API. - type: str - required: false - default: 'https://jbossnetwork.api.redhat.com' - client_id: - description: - - Client ID associated with to download a product from the JBoss Network API. - - If value not set, will try environment variable C(REDHAT_PRODUCT_DOWNLOAD_CLIENT_ID) - type: str - required: false - client_secret: - description: - - Client Secret associated with to download a product from the JBoss Network API. - - If value not set, will try environment variable C(REDHAT_PRODUCT_DOWNLOAD_CLIENT_SECRET) - type: str - required: false - sso_url: - description: - - Address of the Red Hat SSO Server. - type: str - required: false - default: 'https://sso.redhat.com' - validate_certs: - description: - - If C(false), SSL certificates will not be validated. - type: bool - default: yes - required: false - product_category: - description: - - Type of the Product Category - type: str - required: false - product_id: - description: - - Product Id for the Redhat customer portal - type: str - required: false - product_type: - description: - - Type of the Product - type: str - required: false - product_version: - description: - - Product Version to be downloaded. - type: str - required: false - -""" diff --git a/plugins/modules/product_download.py b/plugins/modules/product_download.py index 016ae9e..d1e942b 100644 --- a/plugins/modules/product_download.py +++ b/plugins/modules/product_download.py @@ -44,9 +44,58 @@ description: - Downloads products from the JBoss Network API. extends_documentation_fragment: - - files - - middleware_automation.common.jbossnetwork_connection_options + - ansible.builtin.files options: + api_url: + description: + - Address of the JBoss Network API. + type: str + required: false + default: 'https://jbossnetwork.api.redhat.com' + client_id: + description: + - Client ID associated with to download a product from the JBoss Network API. + - If value not set, will try environment variable C(REDHAT_PRODUCT_DOWNLOAD_CLIENT_ID) + type: str + required: false + client_secret: + description: + - Client Secret associated with to download a product from the JBoss Network API. + - If value not set, will try environment variable C(REDHAT_PRODUCT_DOWNLOAD_CLIENT_SECRET) + type: str + required: false + sso_url: + description: + - Address of the Red Hat SSO Server. + type: str + required: false + default: 'https://sso.redhat.com' + validate_certs: + description: + - If C(false), SSL certificates will not be validated. + type: bool + default: yes + required: false + product_category: + description: + - Type of the Product Category + type: str + required: false + product_id: + description: + - Product Id for the Redhat customer portal + type: str + required: false + product_type: + description: + - Type of the Product + type: str + required: false + product_version: + description: + - Product Version to be downloaded. + type: str + required: false dest: description: - Absolute . diff --git a/plugins/modules/product_search.py b/plugins/modules/product_search.py index da1f90d..9490cd6 100644 --- a/plugins/modules/product_search.py +++ b/plugins/modules/product_search.py @@ -43,8 +43,57 @@ short_description: Searches products from the JBoss Network API. description: - Searches products from the JBoss Network API. -extends_documentation_fragment: - - middleware_automation.common.jbossnetwork_connection_options +options: + api_url: + description: + - Address of the JBoss Network API. + type: str + required: false + default: 'https://jbossnetwork.api.redhat.com' + client_id: + description: + - Client ID associated with to download a product from the JBoss Network API. + - If value not set, will try environment variable C(REDHAT_PRODUCT_DOWNLOAD_CLIENT_ID) + type: str + required: false + client_secret: + description: + - Client Secret associated with to download a product from the JBoss Network API. + - If value not set, will try environment variable C(REDHAT_PRODUCT_DOWNLOAD_CLIENT_SECRET) + type: str + required: false + sso_url: + description: + - Address of the Red Hat SSO Server. + type: str + required: false + default: 'https://sso.redhat.com' + validate_certs: + description: + - If C(false), SSL certificates will not be validated. + type: bool + default: yes + required: false + product_category: + description: + - Type of the Product Category + type: str + required: false + product_id: + description: + - Product Id for the Redhat customer portal + type: str + required: false + product_type: + description: + - Type of the Product + type: str + required: false + product_version: + description: + - Product Version to be downloaded. + type: str + required: false """