diff --git a/docs/alert_contact_point_module.rst b/docs/alert_contact_point_module.rst new file mode 100644 index 0000000..e69de29 diff --git a/docs/alert_notification_policy_module.rst b/docs/alert_notification_policy_module.rst new file mode 100644 index 0000000..e69de29 diff --git a/docs/cloud_api_key_module.rst b/docs/cloud_api_key_module.rst new file mode 100644 index 0000000..e69de29 diff --git a/docs/cloud_plugin_module.rst b/docs/cloud_plugin_module.rst new file mode 100644 index 0000000..e69de29 diff --git a/docs/cloud_stack_module.rst b/docs/cloud_stack_module.rst new file mode 100644 index 0000000..e69de29 diff --git a/docs/dashboard_module.rst b/docs/dashboard_module.rst new file mode 100644 index 0000000..e69de29 diff --git a/docs/datasource_module.rst b/docs/datasource_module.rst new file mode 100644 index 0000000..e69de29 diff --git a/docs/folder_module.rst b/docs/folder_module.rst new file mode 100644 index 0000000..51b33c3 --- /dev/null +++ b/docs/folder_module.rst @@ -0,0 +1,1003 @@ +.. Document meta + +:orphan: + +.. |antsibull-internal-nbsp| unicode:: 0xA0 + :trim: + +.. role:: ansible-attribute-support-label +.. role:: ansible-attribute-support-property +.. role:: ansible-attribute-support-full +.. role:: ansible-attribute-support-partial +.. role:: ansible-attribute-support-none +.. role:: ansible-attribute-support-na +.. role:: ansible-option-type +.. role:: ansible-option-elements +.. role:: ansible-option-required +.. role:: ansible-option-versionadded +.. role:: ansible-option-aliases +.. role:: ansible-option-choices +.. role:: ansible-option-choices-entry +.. role:: ansible-option-default +.. role:: ansible-option-default-bold +.. role:: ansible-option-configuration +.. role:: ansible-option-returned-bold +.. role:: ansible-option-sample-bold + +.. Anchors + +.. _ansible_collections.grafana.grafana.folder_module: + +.. Anchors: short name for ansible.builtin + +.. Anchors: aliases + + + +.. Title + +grafana.grafana.folder module -- Manage Folders in Grafana +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + +.. Collection note + +.. note:: + This module is part of the `grafana.grafana collection `_ (version 0.0.5). + + You might already have this collection installed if you are using the ``ansible`` package. + It is not included in ``ansible-core``. + To check whether it is installed, run :code:`ansible-galaxy collection list`. + + To install it, use: :code:`ansible-galaxy collection install grafana.grafana`. + + To use it in a playbook, specify: :code:`grafana.grafana.folder`. + +.. version_added + +.. versionadded:: 0.0.1 of grafana.grafana + +.. contents:: + :local: + :depth: 1 + +.. Deprecated + + +Synopsis +-------- + +.. Description + +- Create, Update and delete Folders via Ansible. + + +.. Aliases + + +.. Requirements + + + + + + +.. Options + +Parameters +---------- + + +.. rst-class:: ansible-option-table + +.. list-table:: + :width: 100% + :widths: auto + :header-rows: 1 + + * - Parameter + - Comments + + * - .. raw:: html + +
+
+ + .. _ansible_collections.grafana.grafana.folder_module__parameter-cloud_api_key: + + .. rst-class:: ansible-option-title + + **cloud_api_key** + + .. raw:: html + + + + .. rst-class:: ansible-option-type-line + + :ansible-option-type:`string` / :ansible-option-required:`required` + + .. raw:: html + +
+ + - .. raw:: html + +
+ + CLoud API Key to authenticate with Grafana Cloud. + + + .. raw:: html + +
+ + * - .. raw:: html + +
+
+ + .. _ansible_collections.grafana.grafana.folder_module__parameter-overwrite: + + .. rst-class:: ansible-option-title + + **overwrite** + + .. raw:: html + + + + .. rst-class:: ansible-option-type-line + + :ansible-option-type:`string` + + .. raw:: html + +
+ + - .. raw:: html + +
+ + Set to false if you dont want to overwrite existing folder with newer version. + + + .. rst-class:: ansible-option-line + + :ansible-option-default-bold:`Default:` :ansible-option-default:`"yes"` + + .. raw:: html + +
+ + * - .. raw:: html + +
+
+ + .. _ansible_collections.grafana.grafana.folder_module__parameter-state: + + .. rst-class:: ansible-option-title + + **state** + + .. raw:: html + + + + .. rst-class:: ansible-option-type-line + + :ansible-option-type:`string` + + .. raw:: html + +
+ + - .. raw:: html + +
+ + State for the Grafana CLoud stack. + + + .. rst-class:: ansible-option-line + + :ansible-option-choices:`Choices:` + + - :ansible-option-default-bold:`present` :ansible-option-default:`← (default)` + - :ansible-option-choices-entry:`absent` + + .. raw:: html + +
+ + * - .. raw:: html + +
+
+ + .. _ansible_collections.grafana.grafana.folder_module__parameter-title: + + .. rst-class:: ansible-option-title + + **title** + + .. raw:: html + + + + .. rst-class:: ansible-option-type-line + + :ansible-option-type:`string` / :ansible-option-required:`required` + + .. raw:: html + +
+ + - .. raw:: html + +
+ + The title of the folder. + + + .. raw:: html + +
+ + * - .. raw:: html + +
+
+ + .. _ansible_collections.grafana.grafana.folder_module__parameter-uid: + + .. rst-class:: ansible-option-title + + **uid** + + .. raw:: html + + + + .. rst-class:: ansible-option-type-line + + :ansible-option-type:`string` / :ansible-option-required:`required` + + .. raw:: html + +
+ + - .. raw:: html + +
+ + unique identifier for your folder. + + + .. raw:: html + +
+ + +.. Attributes + + +.. Notes + + +.. Seealso + + +.. Examples + +Examples +-------- + +.. code-block:: yaml+jinja + + + - name: Create/Update a Folder in Grafana + folder: + title: folder_name + uid: folder_name + overwrite: true + stack_slug: "{{ stack_slug }}" + cloud_api_key: "{{ grafana_cloud_api_key }}" + state: present + + - name: Delete a Folder in Grafana + folder: + uid: folder_name + stack_slug: "{{ stack_slug }}" + cloud_api_key: "{{ grafana_cloud_api_key }}" + state: absent + + + + +.. Facts + + +.. Return values + +Return Values +------------- +Common return values are documented :ref:`here `, the following are the fields unique to this module: + +.. rst-class:: ansible-option-table + +.. list-table:: + :width: 100% + :widths: auto + :header-rows: 1 + + * - Key + - Description + + * - .. raw:: html + +
+
+ + .. _ansible_collections.grafana.grafana.folder_module__return-output: + + .. rst-class:: ansible-option-title + + **output** + + .. raw:: html + + + + .. rst-class:: ansible-option-type-line + + :ansible-option-type:`dictionary` + + .. raw:: html + +
+ + - .. raw:: html + +
+ + Dict object containing folder information + + + .. rst-class:: ansible-option-line + + :ansible-option-returned-bold:`Returned:` On success + + + .. raw:: html + +
+ + + * - .. raw:: html + +
+
+ + .. _ansible_collections.grafana.grafana.folder_module__return-output/canadmin: + + .. rst-class:: ansible-option-title + + **canAdmin** + + .. raw:: html + + + + .. rst-class:: ansible-option-type-line + + :ansible-option-type:`boolean` + + .. raw:: html + +
+ + - .. raw:: html + +
+ + Boolean value specifying if current user can admin in folder + + + .. rst-class:: ansible-option-line + + :ansible-option-returned-bold:`Returned:` state is present and on success + + + .. raw:: html + +
+ + + * - .. raw:: html + +
+
+ + .. _ansible_collections.grafana.grafana.folder_module__return-output/candelete: + + .. rst-class:: ansible-option-title + + **canDelete** + + .. raw:: html + + + + .. rst-class:: ansible-option-type-line + + :ansible-option-type:`boolean` + + .. raw:: html + +
+ + - .. raw:: html + +
+ + Boolean value specifying if current user can delete the folder + + + .. rst-class:: ansible-option-line + + :ansible-option-returned-bold:`Returned:` state is present and on success + + + .. raw:: html + +
+ + + * - .. raw:: html + +
+
+ + .. _ansible_collections.grafana.grafana.folder_module__return-output/canedit: + + .. rst-class:: ansible-option-title + + **canEdit** + + .. raw:: html + + + + .. rst-class:: ansible-option-type-line + + :ansible-option-type:`boolean` + + .. raw:: html + +
+ + - .. raw:: html + +
+ + Boolean value specifying if current user can edit in folder + + + .. rst-class:: ansible-option-line + + :ansible-option-returned-bold:`Returned:` state is present and on success + + + .. raw:: html + +
+ + + * - .. raw:: html + +
+
+ + .. _ansible_collections.grafana.grafana.folder_module__return-output/cansave: + + .. rst-class:: ansible-option-title + + **canSave** + + .. raw:: html + + + + .. rst-class:: ansible-option-type-line + + :ansible-option-type:`boolean` + + .. raw:: html + +
+ + - .. raw:: html + +
+ + Boolean value specifying if current user can save in folder + + + .. rst-class:: ansible-option-line + + :ansible-option-returned-bold:`Returned:` state is present and on success + + + .. raw:: html + +
+ + + * - .. raw:: html + +
+
+ + .. _ansible_collections.grafana.grafana.folder_module__return-output/created: + + .. rst-class:: ansible-option-title + + **created** + + .. raw:: html + + + + .. rst-class:: ansible-option-type-line + + :ansible-option-type:`string` + + .. raw:: html + +
+ + - .. raw:: html + +
+ + The date when folder was created + + + .. rst-class:: ansible-option-line + + :ansible-option-returned-bold:`Returned:` state is present and on success + + + .. raw:: html + +
+ + + * - .. raw:: html + +
+
+ + .. _ansible_collections.grafana.grafana.folder_module__return-output/createdby: + + .. rst-class:: ansible-option-title + + **createdBy** + + .. raw:: html + + + + .. rst-class:: ansible-option-type-line + + :ansible-option-type:`string` + + .. raw:: html + +
+ + - .. raw:: html + +
+ + The name of the user who created the folder + + + .. rst-class:: ansible-option-line + + :ansible-option-returned-bold:`Returned:` state is present and on success + + + .. raw:: html + +
+ + + * - .. raw:: html + +
+
+ + .. _ansible_collections.grafana.grafana.folder_module__return-output/hasacl: + + .. rst-class:: ansible-option-title + + **hasAcl** + + .. raw:: html + + + + .. rst-class:: ansible-option-type-line + + :ansible-option-type:`boolean` + + .. raw:: html + +
+ + - .. raw:: html + +
+ + Boolean value specifying if folder has acl + + + .. rst-class:: ansible-option-line + + :ansible-option-returned-bold:`Returned:` state is present and on success + + + .. raw:: html + +
+ + + * - .. raw:: html + +
+
+ + .. _ansible_collections.grafana.grafana.folder_module__return-output/id: + + .. rst-class:: ansible-option-title + + **id** + + .. raw:: html + + + + .. rst-class:: ansible-option-type-line + + :ansible-option-type:`integer` + + .. raw:: html + +
+ + - .. raw:: html + +
+ + The ID for the folder + + + .. rst-class:: ansible-option-line + + :ansible-option-returned-bold:`Returned:` on success + + + .. raw:: html + +
+ + + * - .. raw:: html + +
+
+ + .. _ansible_collections.grafana.grafana.folder_module__return-output/message: + + .. rst-class:: ansible-option-title + + **message** + + .. raw:: html + + + + .. rst-class:: ansible-option-type-line + + :ansible-option-type:`string` + + .. raw:: html + +
+ + - .. raw:: html + +
+ + The message returned after the operation on the folder + + + .. rst-class:: ansible-option-line + + :ansible-option-returned-bold:`Returned:` state is absent and on success + + + .. raw:: html + +
+ + + * - .. raw:: html + +
+
+ + .. _ansible_collections.grafana.grafana.folder_module__return-output/title: + + .. rst-class:: ansible-option-title + + **title** + + .. raw:: html + + + + .. rst-class:: ansible-option-type-line + + :ansible-option-type:`string` + + .. raw:: html + +
+ + - .. raw:: html + +
+ + The name of the folder + + + .. rst-class:: ansible-option-line + + :ansible-option-returned-bold:`Returned:` on success + + + .. raw:: html + +
+ + + * - .. raw:: html + +
+
+ + .. _ansible_collections.grafana.grafana.folder_module__return-output/uid: + + .. rst-class:: ansible-option-title + + **uid** + + .. raw:: html + + + + .. rst-class:: ansible-option-type-line + + :ansible-option-type:`string` + + .. raw:: html + +
+ + - .. raw:: html + +
+ + The UID for the folder + + + .. rst-class:: ansible-option-line + + :ansible-option-returned-bold:`Returned:` state is present and on success + + + .. raw:: html + +
+ + + * - .. raw:: html + +
+
+ + .. _ansible_collections.grafana.grafana.folder_module__return-output/updated: + + .. rst-class:: ansible-option-title + + **updated** + + .. raw:: html + + + + .. rst-class:: ansible-option-type-line + + :ansible-option-type:`string` + + .. raw:: html + +
+ + - .. raw:: html + +
+ + The date when the folder was last updated + + + .. rst-class:: ansible-option-line + + :ansible-option-returned-bold:`Returned:` state is present and on success + + + .. raw:: html + +
+ + + * - .. raw:: html + +
+
+ + .. _ansible_collections.grafana.grafana.folder_module__return-output/updatedby: + + .. rst-class:: ansible-option-title + + **updatedBy** + + .. raw:: html + + + + .. rst-class:: ansible-option-type-line + + :ansible-option-type:`string` + + .. raw:: html + +
+ + - .. raw:: html + +
+ + The name of the user who last updated the folder + + + .. rst-class:: ansible-option-line + + :ansible-option-returned-bold:`Returned:` state is present and on success + + + .. raw:: html + +
+ + + * - .. raw:: html + +
+
+ + .. _ansible_collections.grafana.grafana.folder_module__return-output/url: + + .. rst-class:: ansible-option-title + + **url** + + .. raw:: html + + + + .. rst-class:: ansible-option-type-line + + :ansible-option-type:`string` + + .. raw:: html + +
+ + - .. raw:: html + +
+ + The URl for the folder + + + .. rst-class:: ansible-option-line + + :ansible-option-returned-bold:`Returned:` state is present and on success + + + .. raw:: html + +
+ + + * - .. raw:: html + +
+
+ + .. _ansible_collections.grafana.grafana.folder_module__return-output/version: + + .. rst-class:: ansible-option-title + + **version** + + .. raw:: html + + + + .. rst-class:: ansible-option-type-line + + :ansible-option-type:`integer` + + .. raw:: html + +
+ + - .. raw:: html + +
+ + The version of the folder + + + .. rst-class:: ansible-option-line + + :ansible-option-returned-bold:`Returned:` state is present and on success + + + .. raw:: html + +
+ + + + +.. Status (Presently only deprecated) + + +.. Authors + +Authors +~~~~~~~ + +- Ishan Jain (@ishanjainn) + + + +.. Extra links + +Collection links +~~~~~~~~~~~~~~~~ + +.. raw:: html + + + +.. Parsing errors diff --git a/galaxy.yml b/galaxy.yml index f21e4d3..45a6940 100644 --- a/galaxy.yml +++ b/galaxy.yml @@ -2,7 +2,7 @@ namespace: grafana name: grafana -version: 0.0.2 +version: 0.0.5 readme: README.md diff --git a/plugins/modules/alert_contact_point.py b/plugins/modules/alert_contact_point.py index dc91ce2..3984abe 100644 --- a/plugins/modules/alert_contact_point.py +++ b/plugins/modules/alert_contact_point.py @@ -17,7 +17,7 @@ options: required: true uid: description: - - Sets the UID of the Contact point. + - Sets the UID of the Contact point. type: str required: true type: @@ -75,7 +75,7 @@ EXAMPLES = ''' ''' RETURN = r''' -output: +output: description: Dict object containing Contact point information information returned: On success type: dict diff --git a/plugins/modules/alert_notification_policy.py b/plugins/modules/alert_notification_policy.py index 6b9a4a8..cc2a021 100644 --- a/plugins/modules/alert_notification_policy.py +++ b/plugins/modules/alert_notification_policy.py @@ -40,12 +40,12 @@ options: required: true groupInterval: description: - - The waiting time to send a batch of new alerts for that group after the first notification was sent. If empty it will be inherited from the parent policy. + - The wait time to send a batch of new alerts for that group after the first notification was sent. Inherited from the parent policy if empty. type: str default: 5m groupWait: description: - - The waiting time until the initial notification is sent for a new group created by an incoming alert. If empty it will be inherited from the parent policy. + - The wait time until the initial notification is sent for a new group created by an incoming alert. Inherited from the parent policy if empty. type: str default: 30s objectMatchers: @@ -57,7 +57,7 @@ options: repeatInterval: description: - The waiting time to resend an alert after they have successfully been sent. - type: str + type: str default: 4h stack_slug: description: @@ -82,7 +82,7 @@ EXAMPLES = ''' object_matchers: [["env", "=", "Production"]], } ] - + - name: Set nested Notification policies alert_notification_policy: routes: [ @@ -106,7 +106,7 @@ EXAMPLES = ''' ''' RETURN = r''' -output: +output: description: Dict object containing Notification tree information returned: On success type: dict @@ -120,7 +120,7 @@ output: returned: on success type: str provenance: - description: + description: returned: on success type: str receiver: diff --git a/plugins/modules/cloud_plugin.py b/plugins/modules/cloud_plugin.py index f6c3b29..9a4667d 100644 --- a/plugins/modules/cloud_plugin.py +++ b/plugins/modules/cloud_plugin.py @@ -139,7 +139,12 @@ def main(): module.params['state'])(module) if not is_error: - module.exit_json(changed=has_changed, pluginId=result['pluginId'], pluginName=result['pluginName'], pluginSlug=result['pluginSlug'], current_version=result['version'], latest_version=result['latestVersion']) + module.exit_json(changed=has_changed, + pluginId=result['pluginId'], + pluginName=result['pluginName'], + pluginSlug=result['pluginSlug'], + current_version=result['version'], + latest_version=result['latestVersion']) else: module.fail_json(msg=result) diff --git a/plugins/modules/cloud_stack.py b/plugins/modules/cloud_stack.py index 0e5633f..471db50 100644 --- a/plugins/modules/cloud_stack.py +++ b/plugins/modules/cloud_stack.py @@ -17,7 +17,7 @@ options: required: true stack_slug: description: - - Subdomain that the Grafana instance will be available at. For example, if you set the slug to , the instance will be available at https://.grafana.net + - Subdomain of the Grafana instance. For example, if slug is , the instance URL will be https://.grafana.net type: str required: true cloud_api_key: @@ -33,12 +33,12 @@ options: choices: [ us, us-azure, eu, au, eu-azure, prod-ap-southeast-0, prod-gb-south-0, prod-eu-west-3] url: description: - - If you use a custom domain for the instance, you can provide it here. For example, “https://grafana.yourdoman.io”. + - If you use a custom domain for the instance, you can provide it here. For example, “https://grafana.yourdoman.io”. type: str default: https://.grafana.net org_slug: description: - - Name of the organization under which Cloud stack is created. + - Name of the organization under which Cloud stack is created. type: str required: false state: @@ -177,7 +177,15 @@ def main(): module.params['state'])(module) if not is_error: - module.exit_json(changed=has_changed, alertmanager_name=result['amInstanceName'], url=result['url'], id=result['id'], cluster_slug=result['clusterName'], orgID=result['orgId'], loki_url=result['hlInstanceUrl'], prometheus_url=result['hmInstancePromUrl'], tempo_url=result['htInstanceUrl'], alertmanager_url=result['amInstanceUrl']) + module.exit_json(changed=has_changed, + alertmanager_name=result['amInstanceName'], + url=result['url'], id=result['id'], + cluster_slug=result['clusterName'], + orgID=result['orgId'], + loki_url=result['hlInstanceUrl'], + prometheus_url=result['hmInstancePromUrl'], + tempo_url=result['htInstanceUrl'], + alertmanager_url=result['amInstanceUrl']) else: module.fail_json(msg=result) diff --git a/plugins/modules/dashboard.py b/plugins/modules/dashboard.py index bab7fa8..9f09901 100644 --- a/plugins/modules/dashboard.py +++ b/plugins/modules/dashboard.py @@ -50,7 +50,7 @@ EXAMPLES = ''' ''' RETURN = r''' -output: +output: description: Dict object containing folder information returned: On success type: dict diff --git a/plugins/modules/datasource.py b/plugins/modules/datasource.py index 2b5fc19..262f133 100644 --- a/plugins/modules/datasource.py +++ b/plugins/modules/datasource.py @@ -50,7 +50,7 @@ EXAMPLES = ''' ''' RETURN = r''' -output: +output: description: Dict object containing Data source information returned: On success type: dict @@ -85,7 +85,8 @@ def present_datasource(module): if result.status_code == 200: return False, True, result.json() elif result.status_code == 409: - get_id_url = requests.get('https://' + module.params['stack_slug'] + '.grafana.net/api/datasources/id/' + module.params['datasource']['name'], headers={"Authorization": 'Bearer ' + module.params['cloud_api_key']}) + get_id_url = requests.get('https://' + module.params['stack_slug'] + '.grafana.net/api/datasources/id/' + module.params['datasource']['name'], + headers={"Authorization": 'Bearer ' + module.params['cloud_api_key']}) api_url = 'https://' + module.params['stack_slug'] + '.grafana.net/api/datasources/' + str(get_id_url.json()['id']) diff --git a/plugins/modules/folder.py b/plugins/modules/folder.py index ba78483..edbbfe7 100644 --- a/plugins/modules/folder.py +++ b/plugins/modules/folder.py @@ -58,7 +58,7 @@ EXAMPLES = ''' ''' RETURN = r''' -output: +output: description: Dict object containing folder information returned: On success type: dict