diff --git a/plugins/__init__.py b/plugins/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/plugins/module_utils/__init__.py b/plugins/module_utils/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/plugins/module_utils/docs/__init__.py b/plugins/module_utils/docs/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/plugins/module_utils/docs/jenkins_node_info.py b/plugins/module_utils/docs/jenkins_node_info.py new file mode 100644 index 0000000..d68dcfc --- /dev/null +++ b/plugins/module_utils/docs/jenkins_node_info.py @@ -0,0 +1,65 @@ +DOCUMENTATION = r""" +--- +module: jenkins_node + +short_description: Retrieve Jenkins node information +# If this is part of a collection, you need to use semantic versioning, +# i.e. the version is of the form "2.5.0" and not "2.4". +version_added: "0.0.1" + +description: This is my longer description explaining my test module. + +options: + name: + description: The name of the jenkins node. + required: true + type: str + aliases: + - agent + server: + description: URL of the jenkins instance + required: true + type: str + aliases: + - server_url + username: + description: Username to use for authentication to jenkins + required: true + type: str + aliases: + - user + api_token: + description: Jenkins API token for the user + required: true + type: str +author: + - transcaffeine (@transcaffeine) +""" + +EXAMPLES = r""" +# Pass in a message +- name: Retrieve information about the jenkins node named 'my_jenkins_node_name' + finallycoffee.cicd.jenkins_node_info: + name: my_jenkins_node_name + server: https://jenkins.example.org + username: admin + api_token: yoursecretapitokenhere +""" + +RETURN = r""" +# These are examples of possible return values, and in general should use other names for return values. +name: + description: The name of the jenkins node + type: str + returned: always + sample: 'jenkins-agent-jdk21-alpine' +secret: + description: The secret of the agent + type: str + returned: always + sample: 'secretverylongstringwith64chars' +work_dir: + description: The local working directory of the jenkins agent + type: str + returned: always +""" diff --git a/plugins/modules/__init__.py b/plugins/modules/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/plugins/modules/jenkins_node_info.py b/plugins/modules/jenkins_node_info.py index 19c1825..7676f25 100644 --- a/plugins/modules/jenkins_node_info.py +++ b/plugins/modules/jenkins_node_info.py @@ -9,76 +9,15 @@ from typing import TYPE_CHECKING from ansible.module_utils.basic import AnsibleModule from ansible_collections.finallycoffee.cicd.plugins.module_utils.Jenkins import Jenkins +from ansible_collections.finallycoffee.cicd.plugins.module_utils.docs.jenkins_node_info import ( + DOCUMENTATION, + EXAMPLES, + RETURN, +) if TYPE_CHECKING: from typing import Optional, Dict, Any -DOCUMENTATION = r""" ---- -module: jenkins_node - -short_description: Retrieve Jenkins node information -# If this is part of a collection, you need to use semantic versioning, -# i.e. the version is of the form "2.5.0" and not "2.4". -version_added: "0.0.1" - -description: This is my longer description explaining my test module. - -options: - name: - description: The name of the jenkins node. - required: true - type: str - aliases: - - agent - server: - description: URL of the jenkins instance - required: true - type: str - aliases: - - server_url - username: - description: Username to use for authentication to jenkins - required: true - type: str - aliases: - - user - api_token: - description: Jenkins API token for the user - required: true - type: str -author: - - transcaffeine (@transcaffeine) -""" - -EXAMPLES = r""" -# Pass in a message -- name: Retrieve information about the jenkins node named 'my_jenkins_node_name' - finallycoffee.cicd.jenkins_node_info: - name: my_jenkins_node_name - server: https://jenkins.example.org - username: admin - api_token: yoursecretapitokenhere -""" - -RETURN = r""" -# These are examples of possible return values, and in general should use other names for return values. -name: - description: The name of the jenkins node - type: str - returned: always - sample: 'jenkins-agent-jdk21-alpine' -secret: - description: The secret of the agent - type: str - returned: always - sample: 'secretverylongstringwith64chars' -work_dir: - description: The local working directory of the jenkins agent - type: str - returned: always -""" - def run_module(): module_args = dict(