summaryrefslogtreecommitdiffstats
path: root/ansible_collections/grafana
diff options
context:
space:
mode:
Diffstat (limited to 'ansible_collections/grafana')
-rw-r--r--ansible_collections/grafana/grafana/.github/workflows/ci-test.yml83
-rw-r--r--ansible_collections/grafana/grafana/.github/workflows/full-integration-test.yml65
-rw-r--r--ansible_collections/grafana/grafana/.github/workflows/release.yml104
-rw-r--r--ansible_collections/grafana/grafana/CHANGELOG.rst159
-rw-r--r--ansible_collections/grafana/grafana/FILES.json439
-rw-r--r--ansible_collections/grafana/grafana/LICENSE674
-rw-r--r--ansible_collections/grafana/grafana/MANIFEST.json35
-rw-r--r--ansible_collections/grafana/grafana/README.md118
-rw-r--r--ansible_collections/grafana/grafana/changelogs/.plugin-cache.yaml59
-rw-r--r--ansible_collections/grafana/grafana/changelogs/changelog.yaml83
-rw-r--r--ansible_collections/grafana/grafana/changelogs/config.yaml32
-rw-r--r--ansible_collections/grafana/grafana/meta/runtime.yml2
-rw-r--r--ansible_collections/grafana/grafana/plugins/modules/alert_contact_point.py245
-rw-r--r--ansible_collections/grafana/grafana/plugins/modules/alert_notification_policy.py227
-rw-r--r--ansible_collections/grafana/grafana/plugins/modules/cloud_api_key.py147
-rw-r--r--ansible_collections/grafana/grafana/plugins/modules/cloud_plugin.py182
-rw-r--r--ansible_collections/grafana/grafana/plugins/modules/cloud_stack.py228
-rw-r--r--ansible_collections/grafana/grafana/plugins/modules/dashboard.py178
-rw-r--r--ansible_collections/grafana/grafana/plugins/modules/datasource.py187
-rw-r--r--ansible_collections/grafana/grafana/plugins/modules/folder.py254
-rw-r--r--ansible_collections/grafana/grafana/roles/grafana_agent/README.md54
-rw-r--r--ansible_collections/grafana/grafana/roles/grafana_agent/defaults/main.yml20
-rw-r--r--ansible_collections/grafana/grafana/roles/grafana_agent/meta/main.yml25
-rw-r--r--ansible_collections/grafana/grafana/roles/grafana_agent/tasks/main.yml59
-rw-r--r--ansible_collections/grafana/grafana/tests/integration/requirements.txt1
-rw-r--r--ansible_collections/grafana/grafana/tests/integration/targets/alert_contact_point/tasks/main.yml71
-rw-r--r--ansible_collections/grafana/grafana/tests/integration/targets/alert_notification_policy/tasks/main.yml16
-rw-r--r--ansible_collections/grafana/grafana/tests/integration/targets/cloud_api_key/tasks/main.yml43
-rw-r--r--ansible_collections/grafana/grafana/tests/integration/targets/cloud_plugin/tasks/main.yml55
-rw-r--r--ansible_collections/grafana/grafana/tests/integration/targets/cloud_stack/tasks/main.yml30
-rw-r--r--ansible_collections/grafana/grafana/tests/integration/targets/dashboard/tasks/main.yml47
-rw-r--r--ansible_collections/grafana/grafana/tests/integration/targets/datasource/tasks/main.yml23
-rw-r--r--ansible_collections/grafana/grafana/tests/integration/targets/folder/tasks/main.yml28
33 files changed, 3973 insertions, 0 deletions
diff --git a/ansible_collections/grafana/grafana/.github/workflows/ci-test.yml b/ansible_collections/grafana/grafana/.github/workflows/ci-test.yml
new file mode 100644
index 000000000..33f7bbb8e
--- /dev/null
+++ b/ansible_collections/grafana/grafana/.github/workflows/ci-test.yml
@@ -0,0 +1,83 @@
+name: CI Tests
+on:
+ push:
+ branches:
+ - "main"
+ pull_request:
+ schedule:
+ - cron: '0 6 * * *'
+env:
+ NAMESPACE: grafana
+ COLLECTION_NAME: grafana
+
+jobs:
+
+ sanity:
+ name: Sanity (Ⓐ${{ matrix.ansible }})
+ strategy:
+ matrix:
+ ansible:
+ - stable-2.12
+ - stable-2.13
+ - stable-2.14
+ - devel
+ runs-on: ubuntu-20.04
+ steps:
+
+ - name: Check out code
+ uses: actions/checkout@v3
+ with:
+ path: ansible_collections/${{env.NAMESPACE}}/${{env.COLLECTION_NAME}}
+
+ - name: Set up Python
+ uses: actions/setup-python@v3
+ with:
+ python-version: '3.10'
+
+ - name: Install ansible-base (${{ matrix.ansible }})
+ run: pip install https://github.com/ansible/ansible/archive/${{ matrix.ansible }}.tar.gz --disable-pip-version-check
+
+ - name: Run sanity tests
+ run: ansible-test sanity -v --docker --color --coverage
+ working-directory: ./ansible_collections/${{env.NAMESPACE}}/${{env.COLLECTION_NAME}}
+
+ integration:
+ runs-on: ubuntu-20.04
+ name: Integration (Ⓐ${{ matrix.ansible }}-py${{ matrix.python }})
+ strategy:
+ fail-fast: true
+ max-parallel: 1
+ matrix:
+ ansible:
+ - stable-2.13
+ python:
+ - '3.10'
+
+ steps:
+ - name: Check out code
+ uses: actions/checkout@v2
+ with:
+ path: ansible_collections/${{env.NAMESPACE}}/${{env.COLLECTION_NAME}}
+
+ - name: create integration_config
+ working-directory: ansible_collections/${{env.NAMESPACE}}/${{env.COLLECTION_NAME}}/tests/integration
+ run: |
+ cat <<EOF > integration_config.yml
+ stack_name: ${{ secrets.ANSIBLE_TEST_STACK_NAME }}
+ org_name: ${{ secrets.ANSIBLE_TEST_ORG_NAME }}
+ grafana_cloud_api_key: ${{ secrets.ANSIBLE_TEST_CLOUD_API_KEY }}
+ grafana_api_key: ${{ secrets.ANSIBLE_TEST_GRAFANA_API_KEY }}
+ test_stack_name: ${{ secrets.ANSIBLE_TEST_CI_STACK }}
+ EOF
+
+ - name: Set up Python
+ uses: actions/setup-python@v2
+ with:
+ python-version: ${{ matrix.python }}
+
+ - name: Install ansible-base (${{ matrix.ansible }})
+ run: pip install https://github.com/ansible/ansible/archive/${{ matrix.ansible }}.tar.gz --disable-pip-version-check
+
+ - name: Run integration test
+ run: ansible-test integration -v --color --retry-on-error --continue-on-error --diff --python ${{ matrix.python }} --coverage --docker
+ working-directory: ./ansible_collections/${{env.NAMESPACE}}/${{env.COLLECTION_NAME}}
diff --git a/ansible_collections/grafana/grafana/.github/workflows/full-integration-test.yml b/ansible_collections/grafana/grafana/.github/workflows/full-integration-test.yml
new file mode 100644
index 000000000..2654a3688
--- /dev/null
+++ b/ansible_collections/grafana/grafana/.github/workflows/full-integration-test.yml
@@ -0,0 +1,65 @@
+name: Full Integration Test
+on:
+ schedule:
+ - cron: '0 0 * * 0'
+ workflow_dispatch:
+env:
+ NAMESPACE: grafana
+ COLLECTION_NAME: grafana
+
+jobs:
+
+ integration:
+ runs-on: ubuntu-20.04
+ name: ${{ matrix.ansible }}-py${{ matrix.python }}
+ strategy:
+ fail-fast: true
+ max-parallel: 1
+ matrix:
+ ansible:
+ - stable-2.11
+ - stable-2.12
+ - stable-2.13
+ - devel
+ python:
+ - '2.7'
+ - '3.5'
+ - '3.6'
+ - '3.7'
+ - '3.8'
+ - '3.9'
+ - '3.10'
+ exclude:
+ - ansible: stable-2.11
+ python: '3.10'
+
+ steps:
+ - name: Check out code
+ uses: actions/checkout@v2
+ with:
+ path: ansible_collections/${{env.NAMESPACE}}/${{env.COLLECTION_NAME}}
+
+ - name: create integration_config
+ working-directory: ansible_collections/${{env.NAMESPACE}}/${{env.COLLECTION_NAME}}/tests/integration
+ run: |
+ cat <<EOF > integration_config.yml
+ stack_name: ${{ secrets.ANSIBLE_TEST_STACK_NAME }}
+ org_name: ${{ secrets.ANSIBLE_TEST_ORG_NAME }}
+ grafana_cloud_api_key: ${{ secrets.ANSIBLE_TEST_CLOUD_API_KEY }}
+ grafana_api_key: ${{ secrets.ANSIBLE_TEST_GRAFANA_API_KEY }}
+ EOF
+
+ - name: Set up Python
+ uses: actions/setup-python@v2
+ with:
+ python-version: '3.10'
+
+ - name: Install ansible-base (${{ matrix.ansible }})
+ run: pip install https://github.com/ansible/ansible/archive/${{ matrix.ansible }}.tar.gz --disable-pip-version-check
+
+ - name: Run integration test
+ run: ansible-test integration -v --color --retry-on-error --continue-on-error --diff --python ${{ matrix.python }} --docker --coverage
+ working-directory: ./ansible_collections/${{env.NAMESPACE}}/${{env.COLLECTION_NAME}}
+
+ - name: Cooling Period
+ run: sleep 1m
diff --git a/ansible_collections/grafana/grafana/.github/workflows/release.yml b/ansible_collections/grafana/grafana/.github/workflows/release.yml
new file mode 100644
index 000000000..03d012cfe
--- /dev/null
+++ b/ansible_collections/grafana/grafana/.github/workflows/release.yml
@@ -0,0 +1,104 @@
+name: GitHub Release
+on:
+ workflow_dispatch:
+ inputs:
+ version:
+ description: 'Version number to release'
+ required: true
+env:
+ NAMESPACE: grafana
+ COLLECTION_NAME: grafana
+
+jobs:
+ sanity:
+ name: Sanity (Ⓐ${{ matrix.ansible }})
+ strategy:
+ matrix:
+ ansible:
+ - stable-2.12
+ - stable-2.13
+ - stable-2.14
+ - devel
+ runs-on: ubuntu-20.04
+ steps:
+
+ - name: Check out code
+ uses: actions/checkout@v3
+ with:
+ path: ansible_collections/${{env.NAMESPACE}}/${{env.COLLECTION_NAME}}
+
+ - name: Set up Python
+ uses: actions/setup-python@v3
+ with:
+ python-version: '3.10'
+
+ - name: Install ansible-base (${{ matrix.ansible }})
+ run: pip install https://github.com/ansible/ansible/archive/${{ matrix.ansible }}.tar.gz --disable-pip-version-check
+
+ - name: Run sanity tests
+ run: ansible-test sanity -v --docker --color --coverage
+ working-directory: ./ansible_collections/${{env.NAMESPACE}}/${{env.COLLECTION_NAME}}
+
+ integration:
+ runs-on: ubuntu-20.04
+ name: Integration (Ⓐ${{ matrix.ansible }}-py${{ matrix.python }})
+ strategy:
+ fail-fast: true
+ max-parallel: 1
+ matrix:
+ ansible:
+ - stable-2.13
+ python:
+ - '3.10'
+
+ steps:
+ - name: Check out code
+ uses: actions/checkout@v2
+ with:
+ path: ansible_collections/${{env.NAMESPACE}}/${{env.COLLECTION_NAME}}
+
+ - name: create integration_config
+ working-directory: ansible_collections/${{env.NAMESPACE}}/${{env.COLLECTION_NAME}}/tests/integration
+ run: |
+ cat <<EOF > integration_config.yml
+ stack_name: ${{ secrets.ANSIBLE_TEST_STACK_NAME }}
+ org_name: ${{ secrets.ANSIBLE_TEST_ORG_NAME }}
+ grafana_cloud_api_key: ${{ secrets.ANSIBLE_TEST_CLOUD_API_KEY }}
+ grafana_api_key: ${{ secrets.ANSIBLE_TEST_GRAFANA_API_KEY }}
+ EOF
+
+ - name: Set up Python
+ uses: actions/setup-python@v2
+ with:
+ python-version: ${{ matrix.python }}
+
+ - name: Install ansible-base (${{ matrix.ansible }})
+ run: pip install https://github.com/ansible/ansible/archive/${{ matrix.ansible }}.tar.gz --disable-pip-version-check
+
+ - name: Run integration test
+ run: ansible-test integration -v --color --retry-on-error --continue-on-error --diff --python ${{ matrix.python }} --docker --coverage
+ working-directory: ./ansible_collections/${{env.NAMESPACE}}/${{env.COLLECTION_NAME}}
+
+ release:
+ name: Create GitHub Release
+ runs-on: ubuntu-latest
+ needs: [sanity]
+ steps:
+ - name: Checkout
+ uses: actions/checkout@v3
+
+ - name: Set up Python
+ uses: actions/setup-python@v2
+ with:
+ python-version: '3.10'
+
+ - name: Install PyYaml
+ run: pip install pyyaml
+
+ - name: Validate version is published to Galaxy
+ run: curl --head -s -f -o /dev/null https://galaxy.ansible.com/download/grafana-grafana-${{ github.event.inputs.version }}.tar.gz
+
+ - name: Release
+ uses: softprops/action-gh-release@v1
+ with:
+ tag_name: ${{ github.event.inputs.version }}
diff --git a/ansible_collections/grafana/grafana/CHANGELOG.rst b/ansible_collections/grafana/grafana/CHANGELOG.rst
new file mode 100644
index 000000000..e2e5dc7bf
--- /dev/null
+++ b/ansible_collections/grafana/grafana/CHANGELOG.rst
@@ -0,0 +1,159 @@
+=============================
+Grafana.Grafana Release Notes
+=============================
+
+.. contents:: Topics
+
+
+v1.1.1
+======
+
+Release Summary
+---------------
+
+Updated return description and value for grafana.grafana.folder module
+
+Minor Changes
+-------------
+
+- Updated the return message in grafana.grafana.folder module
+
+v1.1.0
+======
+
+Release Summary
+---------------
+
+Added Role to deploy Grafana Agent on linux hosts
+
+Major Changes
+-------------
+
+- Added Role for Grafana Agent
+
+v1.0.5
+======
+
+Release Summary
+---------------
+
+Add Note to modules which don't support Idempotency
+
+Minor Changes
+-------------
+
+- Added Note to datasource and dashboard module about not supporting Idempotency
+
+v1.0.4
+======
+
+Release Summary
+---------------
+
+Bug fixes and idempotency fixes for modules
+
+Major Changes
+-------------
+
+- All modules except dashboard and datasource modules now support idempotency
+
+Minor Changes
+-------------
+
+- All modules use `missing_required_lib`` to compose the message for module.fail_json() when required library is missing from host
+
+Bugfixes
+--------
+
+- Fixed cases where cloud_stack and alert_contact_point modules do not return a tuple when nothing in loop matches
+
+v1.0.3
+======
+
+Minor Changes
+-------------
+
+- Add a fail method to modules source code if `requests` library is not present
+- Fixed markup for arg option in Documenation
+- Updated Documenation with `notes` to specify if the check_mode feature is supported by modules
+- removed `supports_check_mode=True` from source code of modules
+
+v1.0.2
+======
+
+Release Summary
+---------------
+
+Documentation updates with updated description for modules
+
+v1.0.1
+======
+
+Release Summary
+---------------
+
+Documentation updates with updated examples
+
+v1.0.0
+======
+
+Release Summary
+---------------
+
+CI and testing improvements
+
+v0.0.7
+======
+
+Release Summary
+---------------
+
+Documentation update for return values in `grafana.grafana.dashboard`
+
+v0.0.6
+======
+
+Minor Changes
+-------------
+
+- Idempotency updates to cloud_api_key and datasource modules
+
+v0.0.5
+======
+
+Release Summary
+---------------
+
+Documentation update and code cleanup
+
+v0.0.4
+======
+
+Bugfixes
+--------
+
+- Fix an issue with `cloud_stack` idempotency
+
+v0.0.3
+======
+
+Release Summary
+---------------
+
+Documentation update and code cleanup
+
+v0.0.2
+======
+
+Release Summary
+---------------
+
+Updated input parameters description for all modules
+
+v0.0.1
+======
+
+Release Summary
+---------------
+
+It's a release! First version to publish to Ansible Galaxy
diff --git a/ansible_collections/grafana/grafana/FILES.json b/ansible_collections/grafana/grafana/FILES.json
new file mode 100644
index 000000000..149552305
--- /dev/null
+++ b/ansible_collections/grafana/grafana/FILES.json
@@ -0,0 +1,439 @@
+{
+ "files": [
+ {
+ "name": ".",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "LICENSE",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "8b1ba204bb69a0ade2bfcf65ef294a920f6bb361b317dba43c7ef29d96332b9b",
+ "format": 1
+ },
+ {
+ "name": "plugins",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "plugins/modules",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "plugins/modules/cloud_api_key.py",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "ad92af34ba14124db79243297d55d40f7f98655ec838ea1aa2f1b2fc4af11dcd",
+ "format": 1
+ },
+ {
+ "name": "plugins/modules/folder.py",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "c7072d564f6a9afd16dd668e07010c87b58791e94b511fe6f94ea55befa9338a",
+ "format": 1
+ },
+ {
+ "name": "plugins/modules/alert_contact_point.py",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "a000ddc28c98669934b5d30f9f08be04c07b14f34bec82a3845de90c19b4d8bd",
+ "format": 1
+ },
+ {
+ "name": "plugins/modules/cloud_stack.py",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "44aa328d6494368924f0097bae96cb2d3cfec22287da53817702da25b35b65f9",
+ "format": 1
+ },
+ {
+ "name": "plugins/modules/datasource.py",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "7d6bc50da5bbf6c6d140ff1729c18663a42cc9e6224d831615d727f493f83598",
+ "format": 1
+ },
+ {
+ "name": "plugins/modules/dashboard.py",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "98acf3a7df9d574b2fd8d8e649472786ea4c2885924cbcb0e6862d8c4dc45e0e",
+ "format": 1
+ },
+ {
+ "name": "plugins/modules/cloud_plugin.py",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "880d925213311ae4b699df702e848b5a5ae57c27ebd3280d68908848f60558d0",
+ "format": 1
+ },
+ {
+ "name": "plugins/modules/alert_notification_policy.py",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "85b9f18d00b1e7cacb77e46c67cfe8a876e81184e396397dbf636d9170ebfcae",
+ "format": 1
+ },
+ {
+ "name": "tests",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "tests/integration",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "tests/integration/requirements.txt",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "ec72420df5dfbdce4111f715c96338df3b7cb75f58e478d2449c9720e560de8c",
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/datasource",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/datasource/tasks",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/datasource/tasks/main.yml",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "b342deafb0fb490680a798dfc42fa4bf4ba3b8188c9a4aac7ad397f42ad09ead",
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/alert_contact_point",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/alert_contact_point/tasks",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/alert_contact_point/tasks/main.yml",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "5ea8a53327bfcac36da1b74cf3d96c1ab00a9dfaada7f041385ccb50b37dfd23",
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/folder",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/folder/tasks",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/folder/tasks/main.yml",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "78b2f1a855ed12cdd7baff990fc4e54399f41c4af2da0de6e74737e823ad4e3a",
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/cloud_stack",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/cloud_stack/tasks",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/cloud_stack/tasks/main.yml",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "54e2086aeb431d3016a02e4594f3d126ba8825f735a5114d356c573f25b9b3b5",
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/dashboard",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/dashboard/tasks",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/dashboard/tasks/main.yml",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "acdac91a4ec8fca7f99abad3bbc5fd920962e20e02e166f35d5513b6e92fa1b6",
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/cloud_api_key",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/cloud_api_key/tasks",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/cloud_api_key/tasks/main.yml",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "07fc392112316089cd6c5e2048ff5e1d8d6837ae103039e31c6938e4d5f5cff5",
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/alert_notification_policy",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/alert_notification_policy/tasks",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/alert_notification_policy/tasks/main.yml",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "23f171d359577a28d52d24d174d217df537e9a662e01b503bd5c2198d4f00490",
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/cloud_plugin",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/cloud_plugin/tasks",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/cloud_plugin/tasks/main.yml",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "19a6f479071b0a89c376b9cf6789370887b09f071adf9b56332c7932e23ee9ae",
+ "format": 1
+ },
+ {
+ "name": "meta",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "meta/runtime.yml",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "6daa0edca47a8056cd10e7c19b447549fb8accbc248cea597ce04b998e4190ae",
+ "format": 1
+ },
+ {
+ "name": "roles",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "roles/grafana_agent",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "roles/grafana_agent/tasks",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "roles/grafana_agent/tasks/main.yml",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "7419b9d46b754bf838c5907de5dd1c2abc7d5a31ce0c8cc464eaaded1f9733e9",
+ "format": 1
+ },
+ {
+ "name": "roles/grafana_agent/meta",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "roles/grafana_agent/meta/main.yml",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "2bc89c9b41ea94d590cb9f76d7309f89175dd2cbbf698a0b3de4abbf6a2bf62d",
+ "format": 1
+ },
+ {
+ "name": "roles/grafana_agent/README.md",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "c10802a2d7a4139178f2cedbb329146c480226ad956796ce1f9da515c9d89ae7",
+ "format": 1
+ },
+ {
+ "name": "roles/grafana_agent/defaults",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "roles/grafana_agent/defaults/main.yml",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "b3fdc4f593e5eed0dc603f07b7c9864f6bc054266e5b9ea99f03b48b3ddb8cb2",
+ "format": 1
+ },
+ {
+ "name": "changelogs",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "changelogs/config.yaml",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "25b6f12f29b0f34c36cd88dafcdeec34796da955ee5a391a8491d25897b8d2ea",
+ "format": 1
+ },
+ {
+ "name": "changelogs/.plugin-cache.yaml",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "1420e01dfd19a743aa8a1a9ee80d51a235e00a5c5746ca0673d2f12e5a054e82",
+ "format": 1
+ },
+ {
+ "name": "changelogs/changelog.yaml",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "0225d8440fd04c2fa4486e8aaa00a9973e959b2ef933727318dba8018591c371",
+ "format": 1
+ },
+ {
+ "name": "README.md",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "19a0ff9a144be1931b9d65d698607cc96e91bacd3f1107edd6407a490e7a3106",
+ "format": 1
+ },
+ {
+ "name": ".github",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": ".github/workflows",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": ".github/workflows/release.yml",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "f7dab8faa996095d8f73530fc55583a49d0db631a3cd8e1d5abc3d4b5f4fa16c",
+ "format": 1
+ },
+ {
+ "name": ".github/workflows/full-integration-test.yml",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "b1b7961d4550e68cdc8e6d0b2e5dd26aece4cfa12879be7ea987b1f241a702db",
+ "format": 1
+ },
+ {
+ "name": ".github/workflows/ci-test.yml",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "1efd3367382e7027fc954b12a7b8f0c97dfbe69c4a4aee8eb53d9f52e89bafe8",
+ "format": 1
+ },
+ {
+ "name": "CHANGELOG.rst",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "e5e870c176ffe1a69f5458d33a2cde667228b16d9859face63f0814079aed144",
+ "format": 1
+ }
+ ],
+ "format": 1
+} \ No newline at end of file
diff --git a/ansible_collections/grafana/grafana/LICENSE b/ansible_collections/grafana/grafana/LICENSE
new file mode 100644
index 000000000..e72bfddab
--- /dev/null
+++ b/ansible_collections/grafana/grafana/LICENSE
@@ -0,0 +1,674 @@
+ GNU GENERAL PUBLIC LICENSE
+ Version 3, 29 June 2007
+
+ Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+ Preamble
+
+ The GNU General Public License is a free, copyleft license for
+software and other kinds of works.
+
+ The licenses for most software and other practical works are designed
+to take away your freedom to share and change the works. By contrast,
+the GNU General Public License is intended to guarantee your freedom to
+share and change all versions of a program--to make sure it remains free
+software for all its users. We, the Free Software Foundation, use the
+GNU General Public License for most of our software; it applies also to
+any other work released this way by its authors. You can apply it to
+your programs, too.
+
+ When we speak of free software, we are referring to freedom, not
+price. Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+them if you wish), that you receive source code or can get it if you
+want it, that you can change the software or use pieces of it in new
+free programs, and that you know you can do these things.
+
+ To protect your rights, we need to prevent others from denying you
+these rights or asking you to surrender the rights. Therefore, you have
+certain responsibilities if you distribute copies of the software, or if
+you modify it: responsibilities to respect the freedom of others.
+
+ For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must pass on to the recipients the same
+freedoms that you received. You must make sure that they, too, receive
+or can get the source code. And you must show them these terms so they
+know their rights.
+
+ Developers that use the GNU GPL protect your rights with two steps:
+(1) assert copyright on the software, and (2) offer you this License
+giving you legal permission to copy, distribute and/or modify it.
+
+ For the developers' and authors' protection, the GPL clearly explains
+that there is no warranty for this free software. For both users' and
+authors' sake, the GPL requires that modified versions be marked as
+changed, so that their problems will not be attributed erroneously to
+authors of previous versions.
+
+ Some devices are designed to deny users access to install or run
+modified versions of the software inside them, although the manufacturer
+can do so. This is fundamentally incompatible with the aim of
+protecting users' freedom to change the software. The systematic
+pattern of such abuse occurs in the area of products for individuals to
+use, which is precisely where it is most unacceptable. Therefore, we
+have designed this version of the GPL to prohibit the practice for those
+products. If such problems arise substantially in other domains, we
+stand ready to extend this provision to those domains in future versions
+of the GPL, as needed to protect the freedom of users.
+
+ Finally, every program is threatened constantly by software patents.
+States should not allow patents to restrict development and use of
+software on general-purpose computers, but in those that do, we wish to
+avoid the special danger that patents applied to a free program could
+make it effectively proprietary. To prevent this, the GPL assures that
+patents cannot be used to render the program non-free.
+
+ The precise terms and conditions for copying, distribution and
+modification follow.
+
+ TERMS AND CONDITIONS
+
+ 0. Definitions.
+
+ "This License" refers to version 3 of the GNU General Public License.
+
+ "Copyright" also means copyright-like laws that apply to other kinds of
+works, such as semiconductor masks.
+
+ "The Program" refers to any copyrightable work licensed under this
+License. Each licensee is addressed as "you". "Licensees" and
+"recipients" may be individuals or organizations.
+
+ To "modify" a work means to copy from or adapt all or part of the work
+in a fashion requiring copyright permission, other than the making of an
+exact copy. The resulting work is called a "modified version" of the
+earlier work or a work "based on" the earlier work.
+
+ A "covered work" means either the unmodified Program or a work based
+on the Program.
+
+ To "propagate" a work means to do anything with it that, without
+permission, would make you directly or secondarily liable for
+infringement under applicable copyright law, except executing it on a
+computer or modifying a private copy. Propagation includes copying,
+distribution (with or without modification), making available to the
+public, and in some countries other activities as well.
+
+ To "convey" a work means any kind of propagation that enables other
+parties to make or receive copies. Mere interaction with a user through
+a computer network, with no transfer of a copy, is not conveying.
+
+ An interactive user interface displays "Appropriate Legal Notices"
+to the extent that it includes a convenient and prominently visible
+feature that (1) displays an appropriate copyright notice, and (2)
+tells the user that there is no warranty for the work (except to the
+extent that warranties are provided), that licensees may convey the
+work under this License, and how to view a copy of this License. If
+the interface presents a list of user commands or options, such as a
+menu, a prominent item in the list meets this criterion.
+
+ 1. Source Code.
+
+ The "source code" for a work means the preferred form of the work
+for making modifications to it. "Object code" means any non-source
+form of a work.
+
+ A "Standard Interface" means an interface that either is an official
+standard defined by a recognized standards body, or, in the case of
+interfaces specified for a particular programming language, one that
+is widely used among developers working in that language.
+
+ The "System Libraries" of an executable work include anything, other
+than the work as a whole, that (a) is included in the normal form of
+packaging a Major Component, but which is not part of that Major
+Component, and (b) serves only to enable use of the work with that
+Major Component, or to implement a Standard Interface for which an
+implementation is available to the public in source code form. A
+"Major Component", in this context, means a major essential component
+(kernel, window system, and so on) of the specific operating system
+(if any) on which the executable work runs, or a compiler used to
+produce the work, or an object code interpreter used to run it.
+
+ The "Corresponding Source" for a work in object code form means all
+the source code needed to generate, install, and (for an executable
+work) run the object code and to modify the work, including scripts to
+control those activities. However, it does not include the work's
+System Libraries, or general-purpose tools or generally available free
+programs which are used unmodified in performing those activities but
+which are not part of the work. For example, Corresponding Source
+includes interface definition files associated with source files for
+the work, and the source code for shared libraries and dynamically
+linked subprograms that the work is specifically designed to require,
+such as by intimate data communication or control flow between those
+subprograms and other parts of the work.
+
+ The Corresponding Source need not include anything that users
+can regenerate automatically from other parts of the Corresponding
+Source.
+
+ The Corresponding Source for a work in source code form is that
+same work.
+
+ 2. Basic Permissions.
+
+ All rights granted under this License are granted for the term of
+copyright on the Program, and are irrevocable provided the stated
+conditions are met. This License explicitly affirms your unlimited
+permission to run the unmodified Program. The output from running a
+covered work is covered by this License only if the output, given its
+content, constitutes a covered work. This License acknowledges your
+rights of fair use or other equivalent, as provided by copyright law.
+
+ You may make, run and propagate covered works that you do not
+convey, without conditions so long as your license otherwise remains
+in force. You may convey covered works to others for the sole purpose
+of having them make modifications exclusively for you, or provide you
+with facilities for running those works, provided that you comply with
+the terms of this License in conveying all material for which you do
+not control copyright. Those thus making or running the covered works
+for you must do so exclusively on your behalf, under your direction
+and control, on terms that prohibit them from making any copies of
+your copyrighted material outside their relationship with you.
+
+ Conveying under any other circumstances is permitted solely under
+the conditions stated below. Sublicensing is not allowed; section 10
+makes it unnecessary.
+
+ 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
+
+ No covered work shall be deemed part of an effective technological
+measure under any applicable law fulfilling obligations under article
+11 of the WIPO copyright treaty adopted on 20 December 1996, or
+similar laws prohibiting or restricting circumvention of such
+measures.
+
+ When you convey a covered work, you waive any legal power to forbid
+circumvention of technological measures to the extent such circumvention
+is effected by exercising rights under this License with respect to
+the covered work, and you disclaim any intention to limit operation or
+modification of the work as a means of enforcing, against the work's
+users, your or third parties' legal rights to forbid circumvention of
+technological measures.
+
+ 4. Conveying Verbatim Copies.
+
+ You may convey verbatim copies of the Program's source code as you
+receive it, in any medium, provided that you conspicuously and
+appropriately publish on each copy an appropriate copyright notice;
+keep intact all notices stating that this License and any
+non-permissive terms added in accord with section 7 apply to the code;
+keep intact all notices of the absence of any warranty; and give all
+recipients a copy of this License along with the Program.
+
+ You may charge any price or no price for each copy that you convey,
+and you may offer support or warranty protection for a fee.
+
+ 5. Conveying Modified Source Versions.
+
+ You may convey a work based on the Program, or the modifications to
+produce it from the Program, in the form of source code under the
+terms of section 4, provided that you also meet all of these conditions:
+
+ a) The work must carry prominent notices stating that you modified
+ it, and giving a relevant date.
+
+ b) The work must carry prominent notices stating that it is
+ released under this License and any conditions added under section
+ 7. This requirement modifies the requirement in section 4 to
+ "keep intact all notices".
+
+ c) You must license the entire work, as a whole, under this
+ License to anyone who comes into possession of a copy. This
+ License will therefore apply, along with any applicable section 7
+ additional terms, to the whole of the work, and all its parts,
+ regardless of how they are packaged. This License gives no
+ permission to license the work in any other way, but it does not
+ invalidate such permission if you have separately received it.
+
+ d) If the work has interactive user interfaces, each must display
+ Appropriate Legal Notices; however, if the Program has interactive
+ interfaces that do not display Appropriate Legal Notices, your
+ work need not make them do so.
+
+ A compilation of a covered work with other separate and independent
+works, which are not by their nature extensions of the covered work,
+and which are not combined with it such as to form a larger program,
+in or on a volume of a storage or distribution medium, is called an
+"aggregate" if the compilation and its resulting copyright are not
+used to limit the access or legal rights of the compilation's users
+beyond what the individual works permit. Inclusion of a covered work
+in an aggregate does not cause this License to apply to the other
+parts of the aggregate.
+
+ 6. Conveying Non-Source Forms.
+
+ You may convey a covered work in object code form under the terms
+of sections 4 and 5, provided that you also convey the
+machine-readable Corresponding Source under the terms of this License,
+in one of these ways:
+
+ a) Convey the object code in, or embodied in, a physical product
+ (including a physical distribution medium), accompanied by the
+ Corresponding Source fixed on a durable physical medium
+ customarily used for software interchange.
+
+ b) Convey the object code in, or embodied in, a physical product
+ (including a physical distribution medium), accompanied by a
+ written offer, valid for at least three years and valid for as
+ long as you offer spare parts or customer support for that product
+ model, to give anyone who possesses the object code either (1) a
+ copy of the Corresponding Source for all the software in the
+ product that is covered by this License, on a durable physical
+ medium customarily used for software interchange, for a price no
+ more than your reasonable cost of physically performing this
+ conveying of source, or (2) access to copy the
+ Corresponding Source from a network server at no charge.
+
+ c) Convey individual copies of the object code with a copy of the
+ written offer to provide the Corresponding Source. This
+ alternative is allowed only occasionally and noncommercially, and
+ only if you received the object code with such an offer, in accord
+ with subsection 6b.
+
+ d) Convey the object code by offering access from a designated
+ place (gratis or for a charge), and offer equivalent access to the
+ Corresponding Source in the same way through the same place at no
+ further charge. You need not require recipients to copy the
+ Corresponding Source along with the object code. If the place to
+ copy the object code is a network server, the Corresponding Source
+ may be on a different server (operated by you or a third party)
+ that supports equivalent copying facilities, provided you maintain
+ clear directions next to the object code saying where to find the
+ Corresponding Source. Regardless of what server hosts the
+ Corresponding Source, you remain obligated to ensure that it is
+ available for as long as needed to satisfy these requirements.
+
+ e) Convey the object code using peer-to-peer transmission, provided
+ you inform other peers where the object code and Corresponding
+ Source of the work are being offered to the general public at no
+ charge under subsection 6d.
+
+ A separable portion of the object code, whose source code is excluded
+from the Corresponding Source as a System Library, need not be
+included in conveying the object code work.
+
+ A "User Product" is either (1) a "consumer product", which means any
+tangible personal property which is normally used for personal, family,
+or household purposes, or (2) anything designed or sold for incorporation
+into a dwelling. In determining whether a product is a consumer product,
+doubtful cases shall be resolved in favor of coverage. For a particular
+product received by a particular user, "normally used" refers to a
+typical or common use of that class of product, regardless of the status
+of the particular user or of the way in which the particular user
+actually uses, or expects or is expected to use, the product. A product
+is a consumer product regardless of whether the product has substantial
+commercial, industrial or non-consumer uses, unless such uses represent
+the only significant mode of use of the product.
+
+ "Installation Information" for a User Product means any methods,
+procedures, authorization keys, or other information required to install
+and execute modified versions of a covered work in that User Product from
+a modified version of its Corresponding Source. The information must
+suffice to ensure that the continued functioning of the modified object
+code is in no case prevented or interfered with solely because
+modification has been made.
+
+ If you convey an object code work under this section in, or with, or
+specifically for use in, a User Product, and the conveying occurs as
+part of a transaction in which the right of possession and use of the
+User Product is transferred to the recipient in perpetuity or for a
+fixed term (regardless of how the transaction is characterized), the
+Corresponding Source conveyed under this section must be accompanied
+by the Installation Information. But this requirement does not apply
+if neither you nor any third party retains the ability to install
+modified object code on the User Product (for example, the work has
+been installed in ROM).
+
+ The requirement to provide Installation Information does not include a
+requirement to continue to provide support service, warranty, or updates
+for a work that has been modified or installed by the recipient, or for
+the User Product in which it has been modified or installed. Access to a
+network may be denied when the modification itself materially and
+adversely affects the operation of the network or violates the rules and
+protocols for communication across the network.
+
+ Corresponding Source conveyed, and Installation Information provided,
+in accord with this section must be in a format that is publicly
+documented (and with an implementation available to the public in
+source code form), and must require no special password or key for
+unpacking, reading or copying.
+
+ 7. Additional Terms.
+
+ "Additional permissions" are terms that supplement the terms of this
+License by making exceptions from one or more of its conditions.
+Additional permissions that are applicable to the entire Program shall
+be treated as though they were included in this License, to the extent
+that they are valid under applicable law. If additional permissions
+apply only to part of the Program, that part may be used separately
+under those permissions, but the entire Program remains governed by
+this License without regard to the additional permissions.
+
+ When you convey a copy of a covered work, you may at your option
+remove any additional permissions from that copy, or from any part of
+it. (Additional permissions may be written to require their own
+removal in certain cases when you modify the work.) You may place
+additional permissions on material, added by you to a covered work,
+for which you have or can give appropriate copyright permission.
+
+ Notwithstanding any other provision of this License, for material you
+add to a covered work, you may (if authorized by the copyright holders of
+that material) supplement the terms of this License with terms:
+
+ a) Disclaiming warranty or limiting liability differently from the
+ terms of sections 15 and 16 of this License; or
+
+ b) Requiring preservation of specified reasonable legal notices or
+ author attributions in that material or in the Appropriate Legal
+ Notices displayed by works containing it; or
+
+ c) Prohibiting misrepresentation of the origin of that material, or
+ requiring that modified versions of such material be marked in
+ reasonable ways as different from the original version; or
+
+ d) Limiting the use for publicity purposes of names of licensors or
+ authors of the material; or
+
+ e) Declining to grant rights under trademark law for use of some
+ trade names, trademarks, or service marks; or
+
+ f) Requiring indemnification of licensors and authors of that
+ material by anyone who conveys the material (or modified versions of
+ it) with contractual assumptions of liability to the recipient, for
+ any liability that these contractual assumptions directly impose on
+ those licensors and authors.
+
+ All other non-permissive additional terms are considered "further
+restrictions" within the meaning of section 10. If the Program as you
+received it, or any part of it, contains a notice stating that it is
+governed by this License along with a term that is a further
+restriction, you may remove that term. If a license document contains
+a further restriction but permits relicensing or conveying under this
+License, you may add to a covered work material governed by the terms
+of that license document, provided that the further restriction does
+not survive such relicensing or conveying.
+
+ If you add terms to a covered work in accord with this section, you
+must place, in the relevant source files, a statement of the
+additional terms that apply to those files, or a notice indicating
+where to find the applicable terms.
+
+ Additional terms, permissive or non-permissive, may be stated in the
+form of a separately written license, or stated as exceptions;
+the above requirements apply either way.
+
+ 8. Termination.
+
+ You may not propagate or modify a covered work except as expressly
+provided under this License. Any attempt otherwise to propagate or
+modify it is void, and will automatically terminate your rights under
+this License (including any patent licenses granted under the third
+paragraph of section 11).
+
+ However, if you cease all violation of this License, then your
+license from a particular copyright holder is reinstated (a)
+provisionally, unless and until the copyright holder explicitly and
+finally terminates your license, and (b) permanently, if the copyright
+holder fails to notify you of the violation by some reasonable means
+prior to 60 days after the cessation.
+
+ Moreover, your license from a particular copyright holder is
+reinstated permanently if the copyright holder notifies you of the
+violation by some reasonable means, this is the first time you have
+received notice of violation of this License (for any work) from that
+copyright holder, and you cure the violation prior to 30 days after
+your receipt of the notice.
+
+ Termination of your rights under this section does not terminate the
+licenses of parties who have received copies or rights from you under
+this License. If your rights have been terminated and not permanently
+reinstated, you do not qualify to receive new licenses for the same
+material under section 10.
+
+ 9. Acceptance Not Required for Having Copies.
+
+ You are not required to accept this License in order to receive or
+run a copy of the Program. Ancillary propagation of a covered work
+occurring solely as a consequence of using peer-to-peer transmission
+to receive a copy likewise does not require acceptance. However,
+nothing other than this License grants you permission to propagate or
+modify any covered work. These actions infringe copyright if you do
+not accept this License. Therefore, by modifying or propagating a
+covered work, you indicate your acceptance of this License to do so.
+
+ 10. Automatic Licensing of Downstream Recipients.
+
+ Each time you convey a covered work, the recipient automatically
+receives a license from the original licensors, to run, modify and
+propagate that work, subject to this License. You are not responsible
+for enforcing compliance by third parties with this License.
+
+ An "entity transaction" is a transaction transferring control of an
+organization, or substantially all assets of one, or subdividing an
+organization, or merging organizations. If propagation of a covered
+work results from an entity transaction, each party to that
+transaction who receives a copy of the work also receives whatever
+licenses to the work the party's predecessor in interest had or could
+give under the previous paragraph, plus a right to possession of the
+Corresponding Source of the work from the predecessor in interest, if
+the predecessor has it or can get it with reasonable efforts.
+
+ You may not impose any further restrictions on the exercise of the
+rights granted or affirmed under this License. For example, you may
+not impose a license fee, royalty, or other charge for exercise of
+rights granted under this License, and you may not initiate litigation
+(including a cross-claim or counterclaim in a lawsuit) alleging that
+any patent claim is infringed by making, using, selling, offering for
+sale, or importing the Program or any portion of it.
+
+ 11. Patents.
+
+ A "contributor" is a copyright holder who authorizes use under this
+License of the Program or a work on which the Program is based. The
+work thus licensed is called the contributor's "contributor version".
+
+ A contributor's "essential patent claims" are all patent claims
+owned or controlled by the contributor, whether already acquired or
+hereafter acquired, that would be infringed by some manner, permitted
+by this License, of making, using, or selling its contributor version,
+but do not include claims that would be infringed only as a
+consequence of further modification of the contributor version. For
+purposes of this definition, "control" includes the right to grant
+patent sublicenses in a manner consistent with the requirements of
+this License.
+
+ Each contributor grants you a non-exclusive, worldwide, royalty-free
+patent license under the contributor's essential patent claims, to
+make, use, sell, offer for sale, import and otherwise run, modify and
+propagate the contents of its contributor version.
+
+ In the following three paragraphs, a "patent license" is any express
+agreement or commitment, however denominated, not to enforce a patent
+(such as an express permission to practice a patent or covenant not to
+sue for patent infringement). To "grant" such a patent license to a
+party means to make such an agreement or commitment not to enforce a
+patent against the party.
+
+ If you convey a covered work, knowingly relying on a patent license,
+and the Corresponding Source of the work is not available for anyone
+to copy, free of charge and under the terms of this License, through a
+publicly available network server or other readily accessible means,
+then you must either (1) cause the Corresponding Source to be so
+available, or (2) arrange to deprive yourself of the benefit of the
+patent license for this particular work, or (3) arrange, in a manner
+consistent with the requirements of this License, to extend the patent
+license to downstream recipients. "Knowingly relying" means you have
+actual knowledge that, but for the patent license, your conveying the
+covered work in a country, or your recipient's use of the covered work
+in a country, would infringe one or more identifiable patents in that
+country that you have reason to believe are valid.
+
+ If, pursuant to or in connection with a single transaction or
+arrangement, you convey, or propagate by procuring conveyance of, a
+covered work, and grant a patent license to some of the parties
+receiving the covered work authorizing them to use, propagate, modify
+or convey a specific copy of the covered work, then the patent license
+you grant is automatically extended to all recipients of the covered
+work and works based on it.
+
+ A patent license is "discriminatory" if it does not include within
+the scope of its coverage, prohibits the exercise of, or is
+conditioned on the non-exercise of one or more of the rights that are
+specifically granted under this License. You may not convey a covered
+work if you are a party to an arrangement with a third party that is
+in the business of distributing software, under which you make payment
+to the third party based on the extent of your activity of conveying
+the work, and under which the third party grants, to any of the
+parties who would receive the covered work from you, a discriminatory
+patent license (a) in connection with copies of the covered work
+conveyed by you (or copies made from those copies), or (b) primarily
+for and in connection with specific products or compilations that
+contain the covered work, unless you entered into that arrangement,
+or that patent license was granted, prior to 28 March 2007.
+
+ Nothing in this License shall be construed as excluding or limiting
+any implied license or other defenses to infringement that may
+otherwise be available to you under applicable patent law.
+
+ 12. No Surrender of Others' Freedom.
+
+ If conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot convey a
+covered work so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you may
+not convey it at all. For example, if you agree to terms that obligate you
+to collect a royalty for further conveying from those to whom you convey
+the Program, the only way you could satisfy both those terms and this
+License would be to refrain entirely from conveying the Program.
+
+ 13. Use with the GNU Affero General Public License.
+
+ Notwithstanding any other provision of this License, you have
+permission to link or combine any covered work with a work licensed
+under version 3 of the GNU Affero General Public License into a single
+combined work, and to convey the resulting work. The terms of this
+License will continue to apply to the part which is the covered work,
+but the special requirements of the GNU Affero General Public License,
+section 13, concerning interaction through a network will apply to the
+combination as such.
+
+ 14. Revised Versions of this License.
+
+ The Free Software Foundation may publish revised and/or new versions of
+the GNU General Public License from time to time. Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+ Each version is given a distinguishing version number. If the
+Program specifies that a certain numbered version of the GNU General
+Public License "or any later version" applies to it, you have the
+option of following the terms and conditions either of that numbered
+version or of any later version published by the Free Software
+Foundation. If the Program does not specify a version number of the
+GNU General Public License, you may choose any version ever published
+by the Free Software Foundation.
+
+ If the Program specifies that a proxy can decide which future
+versions of the GNU General Public License can be used, that proxy's
+public statement of acceptance of a version permanently authorizes you
+to choose that version for the Program.
+
+ Later license versions may give you additional or different
+permissions. However, no additional obligations are imposed on any
+author or copyright holder as a result of your choosing to follow a
+later version.
+
+ 15. Disclaimer of Warranty.
+
+ THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
+APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
+HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
+OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
+THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
+IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
+ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+ 16. Limitation of Liability.
+
+ IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
+THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
+GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
+USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
+DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
+PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
+EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
+SUCH DAMAGES.
+
+ 17. Interpretation of Sections 15 and 16.
+
+ If the disclaimer of warranty and limitation of liability provided
+above cannot be given local legal effect according to their terms,
+reviewing courts shall apply local law that most closely approximates
+an absolute waiver of all civil liability in connection with the
+Program, unless a warranty or assumption of liability accompanies a
+copy of the Program in return for a fee.
+
+ END OF TERMS AND CONDITIONS
+
+ How to Apply These Terms to Your New Programs
+
+ If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+ To do so, attach the following notices to the program. It is safest
+to attach them to the start of each source file to most effectively
+state the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+ <one line to give the program's name and a brief idea of what it does.>
+ Copyright (C) <year> <name of author>
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <https://www.gnu.org/licenses/>.
+
+Also add information on how to contact you by electronic and paper mail.
+
+ If the program does terminal interaction, make it output a short
+notice like this when it starts in an interactive mode:
+
+ <program> Copyright (C) <year> <name of author>
+ This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+ This is free software, and you are welcome to redistribute it
+ under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License. Of course, your program's commands
+might be different; for a GUI interface, you would use an "about box".
+
+ You should also get your employer (if you work as a programmer) or school,
+if any, to sign a "copyright disclaimer" for the program, if necessary.
+For more information on this, and how to apply and follow the GNU GPL, see
+<https://www.gnu.org/licenses/>.
+
+ The GNU General Public License does not permit incorporating your program
+into proprietary programs. If your program is a subroutine library, you
+may consider it more useful to permit linking proprietary applications with
+the library. If this is what you want to do, use the GNU Lesser General
+Public License instead of this License. But first, please read
+<https://www.gnu.org/licenses/why-not-lgpl.html>. \ No newline at end of file
diff --git a/ansible_collections/grafana/grafana/MANIFEST.json b/ansible_collections/grafana/grafana/MANIFEST.json
new file mode 100644
index 000000000..0ec5f0eb4
--- /dev/null
+++ b/ansible_collections/grafana/grafana/MANIFEST.json
@@ -0,0 +1,35 @@
+{
+ "collection_info": {
+ "namespace": "grafana",
+ "name": "grafana",
+ "version": "1.1.1",
+ "authors": [
+ "Grafana Labs <grafana.com>",
+ "Ishan Jain <ishan.jain@grafana.com>"
+ ],
+ "readme": "README.md",
+ "tags": [
+ "grafana",
+ "observability",
+ "monitoring"
+ ],
+ "description": "Ansible collection to manage Grafana resources",
+ "license": [
+ "GPL-3.0-or-later"
+ ],
+ "license_file": null,
+ "dependencies": {},
+ "repository": "https://github.com/grafana/grafana-ansible-collection",
+ "documentation": "https://docs.ansible.com/ansible/devel/collections/grafana/grafana/index.html",
+ "homepage": null,
+ "issues": "https://github.com/grafana/grafana-ansible-collection/issues"
+ },
+ "file_manifest_file": {
+ "name": "FILES.json",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "e9bef1714ba34f82d3540689acda476e69f2929dc9c19bd978451e1908ecf11d",
+ "format": 1
+ },
+ "format": 1
+} \ No newline at end of file
diff --git a/ansible_collections/grafana/grafana/README.md b/ansible_collections/grafana/grafana/README.md
new file mode 100644
index 000000000..93d90c82b
--- /dev/null
+++ b/ansible_collections/grafana/grafana/README.md
@@ -0,0 +1,118 @@
+# Ansible Collection for Grafana Cloud
+
+[![CI Tests](https://github.com/grafana/grafana-ansible-collection/actions/workflows/ci-test.yml/badge.svg)](https://github.com/grafana/grafana-ansible-collection/actions/workflows/ci-test.yml)
+[![Full Integration Test](https://github.com/grafana/grafana-ansible-collection/actions/workflows/full-integration-test.yml/badge.svg?branch=main)](https://github.com/grafana/grafana-ansible-collection/actions/workflows/full-integration-test.yml)
+
+This collection (grafana.grafana) contains modules and plugins to assist in automating managing of resources in <b>Grafana Cloud</b> with Ansible.
+
+- [Ansible collection Documentation](https://grafana.github.io/grafana-ansible-collection/)
+- [Grafana website](https://grafana.com)
+- [Grafana Cloud website](https://grafana.com/products/cloud/)
+
+## Ansible version compatibility
+The collection is tested and supported with:
+
+* ansible >= 2.9
+
+## Installing the collection
+
+Before using the Grafana collection, you need to install it using the below commoand:
+
+```shell
+ansible-galaxy collection install grafana.grafana
+```
+
+You can also include it in a `requirements.yml` file and install it via ansible-galaxy collection install -r `requirements.yml`, using the format:
+
+```yaml
+---
+collections:
+ - name: grafana.grafana
+```
+A specific version of the collection can be installed by using the version keyword in the `requirements.yml` file:
+
+```yaml
+---
+collections:
+ - name: grafana.grafana
+ version: 1.0.0
+```
+## Using this collection
+
+You can call modules by their Fully Qualified Collection Namespace (FQCN), such as `grafana.grafana.cloud_stack`:
+```yaml
+- name: Using grafana collection
+ hosts: localhost
+ tasks:
+ - name: Create a Grafana Cloud stack
+ grafana.grafana.cloud_stack:
+ name: mystack
+ stack_slug: mystack
+ org_slug: myorg
+ cloud_api_key: "{{ cloud_api_key }}"
+ region: eu
+ state: present
+```
+
+or you can add full namespace and collection name in the `collections` element in your playbook
+```yaml
+- name: Using grafana collection
+ hosts: localhost
+ collection:
+ - grafana.grafana
+ tasks:
+ - name: Create a Grafana Cloud stack
+ cloud_stack:
+ name: mystack
+ stack_slug: mystack
+ org_slug: myorg
+ cloud_api_key: "{{ cloud_api_key }}"
+ region: eu
+ state: present
+```
+
+## Contributing
+We are accepting Github pull requests and issues. There are many ways in which you can participate in the project, for example:
+
+* Submit bugs and feature requests, and help us verify them
+* Submit and review source code changes in Github pull requests
+* Add new modules for more Grafana resources
+
+## Testing and Development
+
+If you want to develop new content for this collection or improve what is already
+here, the easiest way to work on the collection is to clone it into one of the configured
+[`COLLECTIONS_PATHS`](https://docs.ansible.com/ansible/latest/reference_appendices/config.html#collections-paths),
+and work on it there.
+
+### Testing with `ansible-test`
+
+We use `ansible-test` for sanity.
+
+## Releasing, Versioning and Deprecation
+
+This collection follows [Semantic Versioning](https://semver.org/). More details on versioning can be found [in the Ansible docs](https://docs.ansible.com/ansible/latest/dev_guide/developing_collections.html#collection-versions).
+
+We plan to regularly release new minor or bugfix versions once new features or bugfixes have been implemented.
+
+Releasing the current major version on GitHub happens from the `main` branch by the [GitHub Release Workflow](https://github.com/grafana/grafana-ansible-collection/blob/main/.github/workflows/release.yml)
+Before the [GitHub Release Workflow](https://github.com/grafana/grafana-ansible-collection/blob/main/.github/workflows/release.yml) is run, Contributors should push the new version on Ansible Galaxy Manually.
+
+We currently are not planning any deprecations or new major releases. The current landscape includes minor version updates for Module's documentation in 1.1.1.
+
+## Code of Conduct
+This collection follows the Ansible project's [Code of Conduct](https://docs.ansible.com/ansible/devel/community/code_of_conduct.html). Please read and familiarize yourself with this doc
+
+## More information
+
+- [Maintainer guidelines](https://docs.ansible.com/ansible/devel/community/maintainers.html)
+- Subscribe to the [news-for-maintainers](https://github.com/ansible-collections/news-for-maintainers) repo and track announcements there.
+- [Ansible Collection overview](https://github.com/ansible-collections/overview)
+- [Ansible User guide](https://docs.ansible.com/ansible/latest/user_guide/index.html)
+- [Ansible Developer guide](https://docs.ansible.com/ansible/latest/dev_guide/index.html)
+- [Ansible Collection Developer Guide](https://docs.ansible.com/ansible/devel/dev_guide/developing_collections.html)
+- [Ansible Community code of conduct](https://docs.ansible.com/ansible/latest/community/code_of_conduct.html)
+
+## License
+
+GPL-3.0-or-later
diff --git a/ansible_collections/grafana/grafana/changelogs/.plugin-cache.yaml b/ansible_collections/grafana/grafana/changelogs/.plugin-cache.yaml
new file mode 100644
index 000000000..2a55a211f
--- /dev/null
+++ b/ansible_collections/grafana/grafana/changelogs/.plugin-cache.yaml
@@ -0,0 +1,59 @@
+objects:
+ role: {}
+plugins:
+ become: {}
+ cache: {}
+ callback: {}
+ cliconf: {}
+ connection: {}
+ filter: {}
+ httpapi: {}
+ inventory: {}
+ lookup: {}
+ module:
+ alert_contact_point:
+ description: Manage Alerting Contact points in Grafana Cloud
+ name: alert_contact_point
+ namespace: ''
+ version_added: 0.0.1
+ alert_notification_policy:
+ description: Sets the notification policy tree in Alerting on Grafana Cloud
+ name: alert_notification_policy
+ namespace: ''
+ version_added: 0.0.1
+ cloud_api_key:
+ description: Manage Grafana Cloud API keys
+ name: cloud_api_key
+ namespace: ''
+ version_added: 0.0.1
+ cloud_plugin:
+ description: Manage Grafana Cloud Plugins
+ name: cloud_plugin
+ namespace: ''
+ version_added: 0.0.1
+ cloud_stack:
+ description: Manage Grafana Cloud stack
+ name: cloud_stack
+ namespace: ''
+ version_added: 0.0.1
+ dashboard:
+ description: Manage Dashboards in Grafana Cloud
+ name: dashboard
+ namespace: ''
+ version_added: 0.0.1
+ datasource:
+ description: Manage Data sources in Grafana Cloud
+ name: datasource
+ namespace: ''
+ version_added: 0.0.1
+ folder:
+ description: Manage Folders in Grafana Cloud
+ name: folder
+ namespace: ''
+ version_added: 0.0.1
+ netconf: {}
+ shell: {}
+ strategy: {}
+ test: {}
+ vars: {}
+version: 1.1.1
diff --git a/ansible_collections/grafana/grafana/changelogs/changelog.yaml b/ansible_collections/grafana/grafana/changelogs/changelog.yaml
new file mode 100644
index 000000000..080753dba
--- /dev/null
+++ b/ansible_collections/grafana/grafana/changelogs/changelog.yaml
@@ -0,0 +1,83 @@
+ancestor: null
+releases:
+ 0.0.1:
+ changes:
+ release_summary: It's a release! First version to publish to Ansible Galaxy
+ release_date: '2022-08-09'
+ 0.0.2:
+ changes:
+ release_summary: Updated input parameters description for all modules
+ release_date: '2022-08-10'
+ 0.0.3:
+ changes:
+ release_summary: Documentation update and code cleanup
+ release_date: '2022-08-10'
+ 0.0.4:
+ changes:
+ bugfixes:
+ - Fix an issue with `cloud_stack` idempotency
+ release_date: '2022-08-10'
+ 0.0.5:
+ changes:
+ release_summary: Documentation update and code cleanup
+ release_date: '2022-08-10'
+ 0.0.6:
+ changes:
+ minor_changes:
+ - Idempotency updates to cloud_api_key and datasource modules
+ release_date: '2022-08-10'
+ 0.0.7:
+ changes:
+ release_summary: Documentation update for return values in `grafana.grafana.dashboard`
+ release_date: '2022-08-11'
+ 1.0.0:
+ changes:
+ release_summary: CI and testing improvements
+ release_date: '2022-08-16'
+ 1.0.1:
+ changes:
+ release_summary: Documentation updates with updated examples
+ release_date: '2022-08-23'
+ 1.0.2:
+ changes:
+ release_summary: Documentation updates with updated description for modules
+ release_date: '2022-08-30'
+ 1.0.3:
+ changes:
+ minor_changes:
+ - Add a fail method to modules source code if `requests` library is not present
+ - Fixed markup for arg option in Documenation
+ - Updated Documenation with `notes` to specify if the check_mode feature is
+ supported by modules
+ - removed `supports_check_mode=True` from source code of modules
+ release_date: '2022-10-20'
+ 1.0.4:
+ changes:
+ bugfixes:
+ - Fixed cases where cloud_stack and alert_contact_point modules do not return
+ a tuple when nothing in loop matches
+ major_changes:
+ - All modules except dashboard and datasource modules now support idempotency
+ minor_changes:
+ - All modules use `missing_required_lib`` to compose the message for module.fail_json()
+ when required library is missing from host
+ release_summary: Bug fixes and idempotency fixes for modules
+ release_date: '2022-11-01'
+ 1.0.5:
+ changes:
+ minor_changes:
+ - Added Note to datasource and dashboard module about not supporting Idempotency
+ release_summary: Add Note to modules which don't support Idempotency
+ release_date: '2022-11-10'
+ 1.1.0:
+ changes:
+ major_changes:
+ - Added Role for Grafana Agent
+ release_summary: Added Role to deploy Grafana Agent on linux hosts
+ release_date: '2022-11-22'
+ 1.1.1:
+ changes:
+ minor_changes:
+ - Updated the return message in grafana.grafana.folder module
+ release_summary: Updated return description and value for grafana.grafana.folder module
+ release_date: '2023-02-08'
diff --git a/ansible_collections/grafana/grafana/changelogs/config.yaml b/ansible_collections/grafana/grafana/changelogs/config.yaml
new file mode 100644
index 000000000..75f9be3e9
--- /dev/null
+++ b/ansible_collections/grafana/grafana/changelogs/config.yaml
@@ -0,0 +1,32 @@
+changelog_filename_template: ../CHANGELOG.rst
+changelog_filename_version_depth: 0
+changes_file: changelog.yaml
+changes_format: combined
+ignore_other_fragment_extensions: true
+keep_fragments: false
+mention_ancestor: true
+new_plugins_after_name: removed_features
+notesdir: fragments
+prelude_section_name: release_summary
+prelude_section_title: Release Summary
+sanitize_changelog: true
+sections:
+- - major_changes
+ - Major Changes
+- - minor_changes
+ - Minor Changes
+- - breaking_changes
+ - Breaking Changes / Porting Guide
+- - deprecated_features
+ - Deprecated Features
+- - removed_features
+ - Removed Features (previously deprecated)
+- - security_fixes
+ - Security Fixes
+- - bugfixes
+ - Bugfixes
+- - known_issues
+ - Known Issues
+title: Grafana.Grafana
+trivial_section_name: trivial
+use_fqcn: true
diff --git a/ansible_collections/grafana/grafana/meta/runtime.yml b/ansible_collections/grafana/grafana/meta/runtime.yml
new file mode 100644
index 000000000..89a0a2bf3
--- /dev/null
+++ b/ansible_collections/grafana/grafana/meta/runtime.yml
@@ -0,0 +1,2 @@
+---
+requires_ansible: '>=2.11'
diff --git a/ansible_collections/grafana/grafana/plugins/modules/alert_contact_point.py b/ansible_collections/grafana/grafana/plugins/modules/alert_contact_point.py
new file mode 100644
index 000000000..b38cb936d
--- /dev/null
+++ b/ansible_collections/grafana/grafana/plugins/modules/alert_contact_point.py
@@ -0,0 +1,245 @@
+#!/usr/bin/python
+# -*- coding: utf-8 -*-
+
+# Copyright: (c) 2021, Ishan Jain (@ishanjainn)
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+from __future__ import (absolute_import, division, print_function)
+
+DOCUMENTATION = '''
+---
+module: alert_contact_point
+author:
+ - Ishan Jain (@ishanjainn)
+version_added: "0.0.1"
+short_description: Manage Alerting Contact points in Grafana Cloud
+description:
+ - Create, Update and delete Contact points using Ansible.
+requirements: [ "requests >= 1.0.0" ]
+notes:
+ - Does not support C(check_mode).
+options:
+ name:
+ description:
+ - Sets the name of the contact point.
+ type: str
+ required: true
+ uid:
+ description:
+ - Sets the UID of the Contact point.
+ type: str
+ required: true
+ type:
+ description:
+ - Sets Contact point type.
+ type: str
+ required: true
+ settings:
+ description:
+ - Sets Contact point settings.
+ type: dict
+ required: true
+ disableResolveMessage:
+ description:
+ - When set to C(true), Disables the resolve message [OK] that is sent when alerting state returns to C(false).
+ type: bool
+ default: false
+ grafana_api_key:
+ description:
+ - Grafana API Key used to authenticate with Grafana.
+ type: str
+ required : true
+ stack_slug:
+ description:
+ - Name of the Grafana Cloud stack to which the contact points will be added.
+ type: str
+ required: true
+ state:
+ description:
+ - State for the Grafana Cloud stack.
+ choices: [ present, absent ]
+ type: str
+ default: present
+'''
+
+EXAMPLES = '''
+- name: Create/Update Alerting contact point
+ grafana.grafana.alert_contact_point:
+ name: ops-email
+ uid: opsemail
+ type: email
+ settings: {
+ addresses: "ops@mydomain.com,devs@mydomain.com"
+ }
+ stack_slug: "{{ stack_slug }}"
+ grafana_api_key: "{{ grafana_api_key }}"
+ state: present
+
+- name: Delete Alerting contact point
+ grafana.grafana.alert_contact_point:
+ name: ops-email
+ uid: opsemail
+ type: email
+ settings: {
+ addresses: "ops@mydomain.com,devs@mydomain.com"
+ }
+ stack_slug: "{{ stack_slug }}"
+ grafana_api_key: "{{ grafana_api_key }}"
+ state: absent
+'''
+
+RETURN = r'''
+output:
+ description: Dict object containing Contact point information information.
+ returned: On success
+ type: dict
+ contains:
+ disableResolveMessage:
+ description: When set to True, Disables the resolve message [OK] that is sent when alerting state returns to false.
+ returned: state is present and on success
+ type: bool
+ sample: false
+ name:
+ description: The name for the contact point.
+ returned: state is present and on success
+ type: str
+ sample: ops-email
+ settings:
+ description: Contains contact point settings.
+ returned: state is present and on success
+ type: dict
+ sample: {
+ addresses: "ops@mydomain.com,devs@mydomain.com"
+ }
+ uid:
+ description: The UID for the contact point.
+ returned: state is present and on success
+ type: str
+ sample: opsemail
+ type:
+ description: The type of contact point.
+ returned: state is present and on success
+ type: str
+ sample: email
+'''
+
+from ansible.module_utils.basic import AnsibleModule, missing_required_lib
+try:
+ import requests
+ HAS_REQUESTS = True
+except ImportError:
+ HAS_REQUESTS = False
+
+__metaclass__ = type
+
+
+def present_alert_contact_point(module):
+ body = {
+ 'Name': module.params['name'],
+ 'UID': module.params['uid'],
+ 'type': module.params['type'],
+ 'settings': module.params['settings'],
+ 'DisableResolveMessage': module.params['disableResolveMessage']
+ }
+ api_url = 'https://' + module.params['stack_slug'] + '.grafana.net/api/v1/provisioning/contact-points'
+
+ result = requests.post(api_url, json=body, headers={"Authorization": 'Bearer ' + module.params['grafana_api_key']})
+
+ if result.status_code == 202:
+ return False, True, result.json()
+ elif result.status_code == 500:
+ sameConfig = False
+ contactPointInfo = {}
+
+ api_url = 'https://' + module.params['stack_slug'] + '.grafana.net/api/v1/provisioning/contact-points'
+
+ result = requests.get(api_url, headers={"Authorization": 'Bearer ' + module.params['grafana_api_key']})
+
+ for contact_points in result.json():
+ if contact_points['uid'] == module.params['uid']:
+ if (contact_points['name'] == module.params['name'] and contact_points['type'] == module.params['type'] and contact_points['settings']
+ and contact_points['settings'] == module.params['settings']
+ and contact_points['disableResolveMessage'] == module.params['disableResolveMessage']):
+
+ sameConfig = True
+ contactPointInfo = contact_points
+ if sameConfig:
+ return False, False, contactPointInfo
+ else:
+ api_url = 'https://' + module.params['stack_slug'] + '.grafana.net/api/v1/provisioning/contact-points/' + \
+ module.params['uid']
+
+ result = requests.put(api_url, json=body, headers={"Authorization": 'Bearer ' + module.params['grafana_api_key']})
+
+ if result.status_code == 202:
+ api_url = 'https://' + module.params['stack_slug'] + '.grafana.net/api/v1/provisioning/contact-points'
+
+ result = requests.get(api_url, headers={"Authorization": 'Bearer ' + module.params['grafana_api_key']})
+
+ for contact_points in result.json():
+ if contact_points['uid'] == module.params['uid']:
+ return False, True, contact_points
+ else:
+ return True, False, {"status": result.status_code, 'response': result.json()['message']}
+ else:
+ return True, False, {"status": result.status_code, 'response': result.json()['message']}
+
+
+def absent_alert_contact_point(module):
+ already_exists = False
+ api_url = 'https://' + module.params['stack_slug'] + '.grafana.net/api/v1/provisioning/contact-points'
+
+ result = requests.get(api_url, headers={"Authorization": 'Bearer ' + module.params['grafana_api_key']})
+
+ for contact_points in result.json():
+ if contact_points['uid'] == module.params['uid']:
+ already_exists = True
+ if already_exists:
+ api_url = 'https://' + module.params['stack_slug'] + '.grafana.net/api/v1/provisioning/contact-points/' + \
+ module.params['uid']
+
+ result = requests.delete(api_url, headers={"Authorization": 'Bearer ' + module.params['grafana_api_key']})
+
+ if result.status_code == 202:
+ return False, True, result.json()
+ else:
+ return True, False, {"status": result.status_code, 'response': result.json()['message']}
+ else:
+ return True, False, "Alert Contact point does not exist"
+
+
+def main():
+ module_args = dict(
+ name=dict(type='str', required=True),
+ uid=dict(type='str', required=True),
+ type=dict(type='str', required=True),
+ settings=dict(type='dict', required=True),
+ disableResolveMessage=dict(type='bool', required=False, default=False),
+ stack_slug=dict(type='str', required=True),
+ grafana_api_key=dict(type='str', required=True, no_log=True),
+ state=dict(type='str', required=False, default='present', choices=['present', 'absent'])
+ )
+
+ choice_map = {
+ "present": present_alert_contact_point,
+ "absent": absent_alert_contact_point,
+ }
+
+ module = AnsibleModule(
+ argument_spec=module_args
+ )
+
+ if not HAS_REQUESTS:
+ module.fail_json(msg=missing_required_lib('requests'))
+
+ is_error, has_changed, result = choice_map.get(
+ module.params['state'])(module)
+
+ if not is_error:
+ module.exit_json(changed=has_changed, output=result)
+ else:
+ module.fail_json(msg=result)
+
+
+if __name__ == '__main__':
+ main()
diff --git a/ansible_collections/grafana/grafana/plugins/modules/alert_notification_policy.py b/ansible_collections/grafana/grafana/plugins/modules/alert_notification_policy.py
new file mode 100644
index 000000000..f01a798e0
--- /dev/null
+++ b/ansible_collections/grafana/grafana/plugins/modules/alert_notification_policy.py
@@ -0,0 +1,227 @@
+#!/usr/bin/python
+# -*- coding: utf-8 -*-
+
+# Copyright: (c) 2021, Ishan Jain (@ishanjainn)
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+from __future__ import (absolute_import, division, print_function)
+
+DOCUMENTATION = '''
+---
+module: alert_notification_policy
+author:
+ - Ishan Jain (@ishanjainn)
+version_added: "0.0.1"
+short_description: Sets the notification policy tree in Alerting on Grafana Cloud
+description:
+ - Set the notification policy tree using Ansible.
+requirements: [ "requests >= 1.0.0" ]
+notes:
+ - Does not support C(check_mode).
+options:
+ Continue:
+ description:
+ - Continue matching subsequent sibling nodes if set to C(true).
+ type: bool
+ default: false
+ groupByStr:
+ description:
+ - List of string.
+ - Group alerts when you receive a notification based on labels. If empty it will be inherited from the parent policy.
+ type: list
+ default: []
+ elements: str
+ muteTimeIntervals:
+ description:
+ - List of string.
+ - Sets the mute timing for the notfification policy.
+ type: list
+ default: []
+ elements: str
+ rootPolicyReceiver:
+ description:
+ - Sets the name of the contact point to be set as the default receiver.
+ type: str
+ default: grafana-default-email
+ routes:
+ description:
+ - List of objects
+ - Sets the Route that contains definitions of how to handle alerts.
+ type: list
+ required: true
+ elements: dict
+ groupInterval:
+ description:
+ - Sets 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:
+ - Sets 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:
+ description:
+ - Matchers is a slice of Matchers that is sortable, implements Stringer, and provides a Matches method to match a LabelSet.
+ type: list
+ default: []
+ elements: dict
+ repeatInterval:
+ description:
+ - Sets the waiting time to resend an alert after they have successfully been sent.
+ type: str
+ default: 4h
+ stack_slug:
+ description:
+ - Name of the Grafana Cloud stack to which the notification policies will be added.
+ type: str
+ required: true
+ grafana_api_key:
+ description:
+ - Grafana API Key used to authenticate with Grafana.
+ type: str
+ required : true
+'''
+
+EXAMPLES = '''
+- name: Set Notification policy tree
+ grafana.grafana.alert_notification_policy:
+ stack_slug: "{{ stack_slug }}"
+ grafana_api_key: "{{ grafana_api_key }}"
+ routes: [
+ {
+ receiver: myReceiver,
+ object_matchers: [["env", "=", "Production"]],
+ }
+ ]
+
+- name: Set nested Notification policies
+ grafana.grafana.alert_notification_policy:
+ routes: [
+ {
+ receiver: myReceiver,
+ object_matchers: [["env", "=", "Production"],["team", "=", "ops"]],
+ routes: [
+ {
+ receiver: myReceiver2,
+ object_matchers: [["region", "=", "eu"]],
+ }
+ ]
+ },
+ {
+ receiver: myReceiver3,
+ object_matchers: [["env", "=", "Staging"]]
+ }
+ ]
+ stack_slug: "{{ stack_slug }}"
+ grafana_api_key: "{{ grafana_api_key }}"
+'''
+
+RETURN = r'''
+output:
+ description: Dict object containing Notification tree information.
+ returned: On success
+ type: dict
+ contains:
+ group_interval:
+ description: The waiting time to send a batch of new alerts for that group after the first notification was sent. This is of the parent policy.
+ returned: on success
+ type: str
+ sample: "5m"
+ group_wait:
+ description: The waiting time until the initial notification is sent for a new group created by an incoming alert. This is of the parent policy.
+ returned: on success
+ type: str
+ sample: "30s"
+ receiver:
+ description: The name of the default contact point.
+ returned: state is present and on success
+ type: str
+ sample: "grafana-default-email"
+ repeat_interval:
+ description: The waiting time to resend an alert after they have successfully been sent. This is of the parent policy
+ returned: on success
+ type: str
+ sample: "4h"
+ routes:
+ description: The entire notification tree returned as a list.
+ returned: on success
+ type: list
+ sample: [
+ {
+ "object_matchers": [
+ [
+ "env",
+ "=",
+ "Production"
+ ]
+ ],
+ "receiver": "grafana-default-email"
+ }
+ ]
+'''
+
+from ansible.module_utils.basic import AnsibleModule, missing_required_lib
+try:
+ import requests
+ HAS_REQUESTS = True
+except ImportError:
+ HAS_REQUESTS = False
+
+__metaclass__ = type
+
+
+def alert_notification_policy(module):
+ body = {'routes': module.params['routes'], 'Continue': module.params['Continue'],
+ 'groupByStr': module.params['groupByStr'], 'muteTimeIntervals': module.params['muteTimeIntervals'],
+ 'receiver': module.params['rootPolicyReceiver'], 'group_interval': module.params['groupInterval'],
+ 'group_wait': module.params['groupWait'], 'object_matchers': module.params['objectMatchers'],
+ 'repeat_interval': module.params['repeatInterval']}
+
+ api_url = 'https://' + module.params['stack_slug'] + '.grafana.net/api/v1/provisioning/policies'
+ result = requests.get(api_url, headers={"Authorization": 'Bearer ' + module.params['grafana_api_key']})
+
+ if (result.json()['receiver'] == module.params['rootPolicyReceiver'] and result.json()['routes'] == module.params['routes']
+ and result.json()['group_wait'] == module.params['groupWait'] and result.json()['group_interval'] == module.params['groupInterval']
+ and result.json()['repeat_interval'] == module.params['repeatInterval']):
+ return False, False, result.json()
+ else:
+ api_url = 'https://' + module.params['stack_slug'] + '.grafana.net/api/v1/provisioning/policies'
+
+ result = requests.put(api_url, json=body, headers={"Authorization": 'Bearer ' + module.params['grafana_api_key']})
+
+ if result.status_code == 202:
+ return False, True, result.json()
+ else:
+ return True, False, {"status": result.status_code, 'response': result.json()['message']}
+
+
+def main():
+
+ module_args = dict(Continue=dict(type='bool', required=False, default=False),
+ groupByStr=dict(type='list', required=False, default=[], elements='str'),
+ muteTimeIntervals=dict(type='list', required=False, default=[], elements='str'),
+ rootPolicyReceiver=dict(type='str', required=False, default='grafana-default-email'),
+ routes=dict(type='list', required=True, elements='dict'),
+ groupInterval=dict(type='str', required=False, default='5m'),
+ groupWait=dict(type='str', required=False, default='30s'),
+ repeatInterval=dict(type='str', required=False, default='4h'),
+ objectMatchers=dict(type='list', required=False, default=[], elements='dict'),
+ stack_slug=dict(type='str', required=True),
+ grafana_api_key=dict(type='str', required=True, no_log=True), )
+
+ module = AnsibleModule(argument_spec=module_args)
+
+ if not HAS_REQUESTS:
+ module.fail_json(msg=missing_required_lib('requests'))
+
+ is_error, has_changed, result = alert_notification_policy(module)
+
+ if not is_error:
+ module.exit_json(changed=has_changed, output=result)
+ else:
+ module.fail_json(msg='Status code is ' + str(result['status']), output=result['response'])
+
+
+if __name__ == '__main__':
+ main()
diff --git a/ansible_collections/grafana/grafana/plugins/modules/cloud_api_key.py b/ansible_collections/grafana/grafana/plugins/modules/cloud_api_key.py
new file mode 100644
index 000000000..b7c358eca
--- /dev/null
+++ b/ansible_collections/grafana/grafana/plugins/modules/cloud_api_key.py
@@ -0,0 +1,147 @@
+#!/usr/bin/python
+# -*- coding: utf-8 -*-
+
+# Copyright: (c) 2021, Ishan Jain (@ishanjainn)
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+from __future__ import (absolute_import, division, print_function)
+
+DOCUMENTATION = '''
+---
+module: cloud_api_key
+author:
+ - Ishan Jain (@ishanjainn)
+version_added: "0.0.1"
+short_description: Manage Grafana Cloud API keys
+description:
+ - Create and delete Grafana Cloud API keys using Ansible.
+requirements: [ "requests >= 1.0.0" ]
+notes:
+ - Does not support C(check_mode).
+options:
+ name:
+ description:
+ - Sets the name of the Grafana Cloud API key.
+ type: str
+ required: true
+ role:
+ description:
+ - Sets the role to be associated with the Cloud API key.
+ type: str
+ required: true
+ choices: [Admin, Viewer, Editor, MetricsPublisher]
+ org_slug:
+ description:
+ - Name of the Grafana Cloud organization in which Cloud API key will be created.
+ type: str
+ required: true
+ existing_cloud_api_key:
+ description:
+ - Cloud API Key to authenticate with Grafana Cloud.
+ type: str
+ required : true
+ fail_if_already_created:
+ description:
+ - If set to C(true), the task will fail if the API key with same name already exists in the Organization.
+ type: bool
+ default: True
+ state:
+ description:
+ - State for the Grafana Cloud stack.
+ type: str
+ default: present
+ choices: [ present, absent ]
+'''
+
+EXAMPLES = '''
+- name: Create Grafana Cloud API key
+ grafana.grafana.cloud_api_key:
+ name: key_name
+ role: Admin
+ org_slug: "{{ org_slug }}"
+ existing_cloud_api_key: "{{ grafana_cloud_api_key }}"
+ fail_if_already_created: False
+ state: present
+
+- name: Delete Grafana Cloud API key
+ grafana.grafana.cloud_api_key:
+ name: key_name
+ org_slug: "{{ org_slug }}"
+ existing_cloud_api_key: "{{ grafana_cloud_api_key }}"
+ state: absent
+'''
+
+from ansible.module_utils.basic import AnsibleModule, missing_required_lib
+try:
+ import requests
+ HAS_REQUESTS = True
+except ImportError:
+ HAS_REQUESTS = False
+
+__metaclass__ = type
+
+
+def present_cloud_api_key(module):
+ body = {
+ 'name': module.params['name'],
+ 'role': module.params['role']
+ }
+
+ api_url = 'https://grafana.com/api/orgs/' + module.params['org_slug'] + '/api-keys'
+
+ result = requests.post(api_url, json=body,
+ headers={"Authorization": 'Bearer ' + module.params['existing_cloud_api_key']})
+
+ if result.status_code == 200:
+ return False, True, result.json()
+ elif result.status_code == 409:
+ return module.params['fail_if_already_created'], False, "A Cloud API key with the same name already exists"
+ else:
+ return True, False, {"status": result.status_code, 'response': result.json()['message']}
+
+
+def absent_cloud_api_key(module):
+ api_url = 'https://grafana.com/api/orgs/' + module.params['org_slug'] + '/api-keys/' + module.params['name']
+
+ result = requests.delete(api_url, headers={"Authorization": 'Bearer ' + module.params['existing_cloud_api_key']})
+
+ if result.status_code == 200:
+ return False, True, "Cloud API key is deleted"
+ else:
+ return True, False, {"status": result.status_code, 'response': result.json()['message']}
+
+
+def main():
+
+ module_args = dict(
+ name=dict(type='str', required=True),
+ role=dict(type='str', required=True, choices=['Admin', 'Viewer', 'Editor', 'MetricsPublisher']),
+ org_slug=dict(type='str', required=True),
+ existing_cloud_api_key=dict(type='str', required=True, no_log=True),
+ fail_if_already_created=dict(type='bool', required=False, default='True'),
+ state=dict(type='str', required=False, default='present', choices=['present', 'absent'])
+ )
+
+ choice_map = {
+ "present": present_cloud_api_key,
+ "absent": absent_cloud_api_key,
+ }
+
+ module = AnsibleModule(
+ argument_spec=module_args
+ )
+
+ if not HAS_REQUESTS:
+ module.fail_json(msg=missing_required_lib('requests'))
+
+ is_error, has_changed, result = choice_map.get(
+ module.params['state'])(module)
+
+ if not is_error:
+ module.exit_json(changed=has_changed, output=result)
+ else:
+ module.fail_json(msg=result)
+
+
+if __name__ == '__main__':
+ main()
diff --git a/ansible_collections/grafana/grafana/plugins/modules/cloud_plugin.py b/ansible_collections/grafana/grafana/plugins/modules/cloud_plugin.py
new file mode 100644
index 000000000..a6399b644
--- /dev/null
+++ b/ansible_collections/grafana/grafana/plugins/modules/cloud_plugin.py
@@ -0,0 +1,182 @@
+#!/usr/bin/python
+# -*- coding: utf-8 -*-
+
+# Copyright: (c) 2021, Ishan Jain (@ishanjainn)
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+from __future__ import (absolute_import, division, print_function)
+
+DOCUMENTATION = '''
+---
+module: cloud_plugin
+author:
+ - Ishan Jain (@ishanjainn)
+version_added: "0.0.1"
+short_description: Manage Grafana Cloud Plugins
+description:
+ - Create, Update and delete Grafana Cloud stacks using Ansible.
+requirements: [ "requests >= 1.0.0" ]
+notes:
+ - Does not support C(check_mode).
+options:
+ name:
+ description:
+ - Name of the plugin, e.g. grafana-github-datasource.
+ type: str
+ required: true
+ version:
+ description:
+ - Version of the plugin to install.
+ type: str
+ default: latest
+ stack_slug:
+ description:
+ - Name of the Grafana Cloud stack to which the plugin will be added.
+ type: str
+ required: true
+ cloud_api_key:
+ description:
+ - Cloud API Key to authenticate with Grafana Cloud.
+ type: str
+ required : true
+ state:
+ description:
+ - State for the Grafana Cloud stack.
+ type: str
+ default: present
+ choices: [ present, absent ]
+'''
+
+EXAMPLES = '''
+- name: Create/Update a plugin
+ grafana.grafana.cloud_plugin:
+ name: grafana-github-datasource
+ version: 1.0.14
+ stack_slug: "{{ stack_slug }}"
+ cloud_api_key: "{{ grafana_cloud_api_key }}"
+ state: present
+
+- name: Delete a Grafana Cloud stack
+ grafana.grafana.cloud_plugin:
+ name: grafana-github-datasource
+ stack_slug: "{{ stack_slug }}"
+ cloud_api_key: "{{ grafana_cloud_api_key }}"
+ state: absent
+'''
+
+RETURN = r'''
+ current_version:
+ description: Current version of the plugin.
+ returned: On success
+ type: str
+ sample: "1.0.14"
+ latest_version:
+ description: Latest version available for the plugin.
+ returned: On success
+ type: str
+ sample: "1.0.15"
+ pluginId:
+ description: Id for the Plugin.
+ returned: On success
+ type: int
+ sample: 663
+ pluginName:
+ description: Name of the plugin.
+ returned: On success
+ type: str
+ sample: "GitHub"
+ pluginSlug:
+ description: Slug for the Plugin.
+ returned: On success
+ type: str
+ sample: "grafana-github-datasource"
+'''
+
+from ansible.module_utils.basic import AnsibleModule, missing_required_lib
+try:
+ import requests
+ HAS_REQUESTS = True
+except ImportError:
+ HAS_REQUESTS = False
+
+__metaclass__ = type
+
+
+def present_cloud_plugin(module):
+ body = {
+ 'plugin': module.params['name'],
+ 'version': module.params['version']
+ }
+
+ api_url = 'https://grafana.com/api/instances/' + module.params['stack_slug'] + '/plugins'
+
+ result = requests.post(api_url, json=body, headers={"Authorization": 'Bearer ' + module.params['cloud_api_key']})
+
+ if result.status_code == 200:
+ return False, True, result.json()
+ elif result.status_code == 409:
+ api_url = 'https://grafana.com/api/instances/' + module.params['stack_slug'] + '/plugins/' + module.params['name']
+ result = requests.get(api_url, headers={"Authorization": 'Bearer ' + module.params['cloud_api_key']})
+
+ if result.json()['pluginSlug'] == module.params['name'] and result.json()['version'] == module.params['version']:
+ return False, False, result.json()
+ else:
+ api_url = 'https://grafana.com/api/instances/' + module.params['stack_slug'] + '/plugins/' + module.params[
+ 'name']
+ result = requests.post(api_url, json={'version': module.params['version']},
+ headers={"Authorization": 'Bearer ' + module.params['cloud_api_key']})
+
+ return False, True, result.json()
+ else:
+ return True, False, {"status": result.status_code, 'response': result.json()['message']}
+
+
+def absent_cloud_plugin(module):
+ api_url = 'https://grafana.com/api/instances/' + module.params['stack_slug'] + '/plugins/' + module.params['name']
+
+ result = requests.delete(api_url, headers={"Authorization": 'Bearer ' + module.params['cloud_api_key']})
+
+ if result.status_code == 200:
+ return False, True, result.json()
+ else:
+ return True, False, {"status": result.status_code, 'response': result.json()['message']}
+
+
+def main():
+
+ module_args = dict(
+ name=dict(type='str', required=True),
+ version=dict(type='str', required=False, default='latest'),
+ stack_slug=dict(type='str', required=True),
+ cloud_api_key=dict(type='str', required=True, no_log=True),
+ state=dict(type='str', required=False, default='present', choices=['present', 'absent'])
+ )
+
+ choice_map = {
+ "present": present_cloud_plugin,
+ "absent": absent_cloud_plugin,
+ }
+
+ module = AnsibleModule(
+ argument_spec=module_args
+ )
+
+ if not HAS_REQUESTS:
+ module.fail_json(msg=missing_required_lib('requests'))
+
+ is_error, has_changed, result = choice_map.get(
+ 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'])
+ else:
+ module.fail_json(msg=result)
+
+
+if __name__ == '__main__':
+ main()
diff --git a/ansible_collections/grafana/grafana/plugins/modules/cloud_stack.py b/ansible_collections/grafana/grafana/plugins/modules/cloud_stack.py
new file mode 100644
index 000000000..ea449bd2b
--- /dev/null
+++ b/ansible_collections/grafana/grafana/plugins/modules/cloud_stack.py
@@ -0,0 +1,228 @@
+#!/usr/bin/python
+# -*- coding: utf-8 -*-
+
+# Copyright: (c) 2021, Ishan Jain (@ishanjainn)
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+from __future__ import (absolute_import, division, print_function)
+
+DOCUMENTATION = '''
+---
+module: cloud_stack
+author:
+ - Ishan Jain (@ishanjainn)
+version_added: "0.0.1"
+short_description: Manage Grafana Cloud stack
+description:
+ - Create and delete Grafana Cloud stacks using Ansible.
+requirements: [ "requests >= 1.0.0" ]
+notes:
+ - Does not support C(check_mode).
+options:
+ name:
+ description:
+ - Sets the name of stack. Conventionally matches the URL of the instance. For example, C(stackslug.grafana.net).
+ type: str
+ required: true
+ stack_slug:
+ description:
+ - Sets the subdomain of the Grafana instance. For example, if slug is B(stackslug), the instance URL will be C(https://stackslug.grafana.net).
+ type: str
+ required: true
+ cloud_api_key:
+ description:
+ - Cloud API Key to authenticate with Grafana Cloud.
+ type: str
+ required : true
+ region:
+ description:
+ - Sets the region for the Grafana Cloud stack.
+ type: str
+ default: us
+ 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. If not provided, Will be set to C(https://stackslug.grafana.net).
+ type: str
+ org_slug:
+ description:
+ - Name of the organization under which Cloud stack is created.
+ type: str
+ required: true
+ state:
+ description:
+ - State for the Grafana Cloud stack.
+ type: str
+ default: present
+ choices: [ present, absent ]
+'''
+
+EXAMPLES = '''
+- name: Create a Grafana Cloud stack
+ grafana.grafana.cloud_stack:
+ name: stack_name
+ stack_slug: stack_name
+ cloud_api_key: "{{ grafana_cloud_api_key }}"
+ region: eu
+ url: https://grafana.company_name.com
+ org_slug: org_name
+ state: present
+
+- name: Delete a Grafana Cloud stack
+ grafana.grafana.cloud_stack:
+ name: stack_name
+ slug: stack_name
+ cloud_api_key: "{{ grafana_cloud_api_key }}"
+ org_slug: org_name
+ state: absent
+'''
+
+RETURN = r'''
+ alertmanager_name:
+ description: Name of the alertmanager instance.
+ returned: always
+ type: str
+ sample: "stackname-alerts"
+ alertmanager_url:
+ description: URL of the alertmanager instance.
+ returned: always
+ type: str
+ sample: "https://alertmanager-eu-west-0.grafana.net"
+ cluster_slug:
+ description: Slug for the cluster where the Grafana stack is deployed.
+ returned: always
+ type: str
+ sample: "prod-eu-west-0"
+ id:
+ description: ID of the Grafana Cloud stack.
+ returned: always
+ type: int
+ sample: 458182
+ loki_url:
+ description: URl for the Loki instance.
+ returned: always
+ type: str
+ sample: "https://logs-prod-eu-west-0.grafana.net"
+ orgID:
+ description: ID of the Grafana Cloud organization.
+ returned: always
+ type: int
+ sample: 652992
+ prometheus_url:
+ description: URl for the Prometheus instance.
+ returned: always
+ type: str
+ sample: "https://prometheus-prod-01-eu-west-0.grafana.net"
+ tempo_url:
+ description: URl for the Tempo instance.
+ returned: always
+ type: str
+ sample: "https://tempo-eu-west-0.grafana.net"
+ url:
+ description: URL of the Grafana Cloud stack.
+ returned: always
+ type: str
+ sample: "https://stackname.grafana.net"
+'''
+
+from ansible.module_utils.basic import AnsibleModule, missing_required_lib
+try:
+ import requests
+ HAS_REQUESTS = True
+except ImportError:
+ HAS_REQUESTS = False
+
+__metaclass__ = type
+
+
+def present_cloud_stack(module):
+ if not module.params['url']:
+ module.params['url'] = 'https://' + module.params['stack_slug'] + '.grafana.net'
+
+ body = {
+ 'name': module.params['name'],
+ 'slug': module.params['stack_slug'],
+ 'region': module.params['region'],
+ 'url': module.params['url']
+ }
+ api_url = 'https://grafana.com/api/instances'
+
+ result = requests.post(api_url, json=body, headers={"Authorization": 'Bearer ' + module.params['cloud_api_key']})
+ if result.status_code == 200:
+ return False, True, result.json()
+ elif result.status_code in [409, 403] and result.json()['message'] in ["That url is not available", "Hosted instance limit reached"]:
+ stack_found = False
+ if result.json['message'] == "That url is not available":
+ api_url = 'https://grafana.com/api/orgs/' + module.params['org_slug'] + '/instances'
+ result = requests.get(api_url, headers={"Authorization": 'Bearer ' + module.params['cloud_api_key']})
+ stackInfo = {}
+ for stack in result.json()['items']:
+ if stack['slug'] == module.params['stack_slug']:
+ stack_found = True
+ stackInfo = stack
+ if stack_found:
+ return False, False, stackInfo
+ else:
+ return True, False, "Stack is not found under your org"
+ elif result.json['message'] == "Hosted instance limit reached":
+ return True, False, "You have reached Maximum number of Cloud Stacks in your Org."
+ else:
+ return True, False, {"status": result.status_code, 'response': result.json()['message']}
+
+
+def absent_cloud_stack(module):
+ api_url = 'https://grafana.com/api/instances/' + module.params['stack_slug']
+
+ result = requests.delete(api_url, headers={"Authorization": 'Bearer ' + module.params['cloud_api_key']})
+
+ if result.status_code == 200:
+ return False, True, result.json()
+ else:
+ return True, False, {"status": result.status_code, 'response': result.json()['message']}
+
+
+def main():
+
+ module_args = dict(
+ name=dict(type='str', required=True),
+ stack_slug=dict(type='str', required=True),
+ cloud_api_key=dict(type='str', required=True, no_log=True),
+ region=dict(type='str', required=False, default='us',
+ choices=['us', 'us-azure', 'eu', 'au', 'eu-azure', 'prod-ap-southeast-0', 'prod-gb-south-0',
+ 'prod-eu-west-3']),
+ url=dict(type='str', required=False),
+ org_slug=dict(type='str', required=True),
+ state=dict(type='str', required=False, default='present', choices=['present', 'absent'])
+ )
+
+ choice_map = {
+ "present": present_cloud_stack,
+ "absent": absent_cloud_stack,
+ }
+
+ module = AnsibleModule(
+ argument_spec=module_args
+ )
+
+ if not HAS_REQUESTS:
+ module.fail_json(msg=missing_required_lib('requests'))
+
+ is_error, has_changed, result = choice_map.get(
+ 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'])
+ else:
+ module.fail_json(msg=result)
+
+
+if __name__ == '__main__':
+ main()
diff --git a/ansible_collections/grafana/grafana/plugins/modules/dashboard.py b/ansible_collections/grafana/grafana/plugins/modules/dashboard.py
new file mode 100644
index 000000000..df8bb33ea
--- /dev/null
+++ b/ansible_collections/grafana/grafana/plugins/modules/dashboard.py
@@ -0,0 +1,178 @@
+#!/usr/bin/python
+# -*- coding: utf-8 -*-
+
+# Copyright: (c) 2021, Ishan Jain (@ishanjainn)
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+from __future__ import (absolute_import, division, print_function)
+
+DOCUMENTATION = '''
+---
+module: dashboard
+author:
+ - Ishan Jain (@ishanjainn)
+version_added: "0.0.1"
+short_description: Manage Dashboards in Grafana Cloud
+description:
+ - Create, Update and delete Dashboards using Ansible.
+requirements: [ "requests >= 1.0.0" ]
+notes:
+ - Does not support C(check_mode).
+ - Does not support C(Idempotency).
+options:
+ dashboard:
+ description:
+ - JSON source code for dashboard.
+ type: dict
+ required: true
+ stack_slug:
+ description:
+ - Name of the Grafana Cloud stack to which the dashboard will be added.
+ type: str
+ required: true
+ grafana_api_key:
+ description:
+ - Grafana API Key to authenticate with Grafana Cloud.
+ type: str
+ required : true
+ state:
+ description:
+ - State for the Grafana Cloud stack.
+ choices: [ present, absent ]
+ default: present
+ type: str
+'''
+
+EXAMPLES = '''
+- name: Create/Update a dashboard
+ grafana.grafana.dashboard:
+ dashboard: "{{ lookup('ansible.builtin.file', 'dashboard.json') }}"
+ stack_slug: "{{ stack_slug }}"
+ grafana_api_key: "{{ grafana_api_key }}"
+ state: present
+
+- name: Delete dashboard
+ grafana.grafana.dashboard:
+ dashboard: "{{ lookup('ansible.builtin.file', 'dashboard.json') }}"
+ stack_slug: "{{ stack_slug }}"
+ grafana_api_key: "{{ grafana_api_key }}"
+ state: absent
+'''
+
+RETURN = r'''
+output:
+ description: Dict object containing folder information.
+ returned: On success
+ type: dict
+ contains:
+ id:
+ description: The ID for the dashboard.
+ returned: on success
+ type: int
+ sample: 17
+ slug:
+ description: The slug for the dashboard.
+ returned: state is present and on success
+ type: str
+ sample: ansible-integration-test
+ status:
+ description: The status of the dashboard.
+ returned: state is present and on success
+ type: str
+ sample: success
+ uid:
+ description: The UID for the dashboard.
+ returned: state is present and on success
+ type: str
+ sample: "test1234"
+ url:
+ description: The endpoint for the dashboard.
+ returned: state is present and on success
+ type: str
+ sample: "/d/test1234/ansible-integration-test"
+ version:
+ description: The version of the dashboard.
+ returned: state is present and on success
+ type: int
+ sample: 2
+ message:
+ description: The message returned after the operation on the dashboard.
+ returned: state is absent and on success
+ type: str
+ sample: "Dashboard Ansible Integration Test deleted"
+ title:
+ description: The name of the dashboard.
+ returned: state is absent and on success
+ type: str
+ sample: "Ansible Integration Test"
+'''
+
+from ansible.module_utils.basic import AnsibleModule, missing_required_lib
+try:
+ import requests
+ HAS_REQUESTS = True
+except ImportError:
+ HAS_REQUESTS = False
+
+
+__metaclass__ = type
+
+
+def present_dashboard(module):
+
+ api_url = 'https://' + module.params['stack_slug'] + '.grafana.net/api/dashboards/db'
+
+ result = requests.post(api_url, json=module.params['dashboard'], headers={"Authorization": 'Bearer ' + module.params['grafana_api_key']})
+
+ if result.status_code == 200:
+ return False, True, result.json()
+ else:
+ return True, False, {"status": result.status_code, 'response': result.json()['message']}
+
+
+def absent_dashboard(module):
+ if 'uid' not in module.params['dashboard']['dashboard']:
+ return True, False, "UID is not defined in the the Dashboard configuration"
+
+ api_url = api_url = 'https://' + module.params['stack_slug'] + '.grafana.net/api/dashboards/uid/' + module.params['dashboard']['dashboard']['uid']
+
+ result = requests.delete(api_url, headers={"Authorization": 'Bearer ' + module.params['grafana_api_key']})
+
+ if result.status_code == 200:
+ return False, True, result.json()
+ else:
+ return True, False, {"status": result.status_code, 'response': result.json()['message']}
+
+
+def main():
+
+ module_args = dict(
+ dashboard=dict(type='dict', required=True),
+ stack_slug=dict(type='str', required=True),
+ grafana_api_key=dict(type='str', required=True, no_log=True),
+ state=dict(type='str', required=False, default='present', choices=['present', 'absent'])
+ )
+
+ choice_map = {
+ "present": present_dashboard,
+ "absent": absent_dashboard,
+ }
+
+ module = AnsibleModule(
+ argument_spec=module_args
+ )
+
+ if not HAS_REQUESTS:
+ module.fail_json(msg=missing_required_lib('requests'))
+
+ is_error, has_changed, result = choice_map.get(
+ module.params['state'])(module)
+
+ if not is_error:
+ module.exit_json(changed=has_changed, output=result)
+ else:
+ module.fail_json(msg=result)
+
+
+if __name__ == '__main__':
+ main()
diff --git a/ansible_collections/grafana/grafana/plugins/modules/datasource.py b/ansible_collections/grafana/grafana/plugins/modules/datasource.py
new file mode 100644
index 000000000..3c9d150bc
--- /dev/null
+++ b/ansible_collections/grafana/grafana/plugins/modules/datasource.py
@@ -0,0 +1,187 @@
+#!/usr/bin/python
+# -*- coding: utf-8 -*-
+
+# Copyright: (c) 2021, Ishan Jain (@ishanjainn)
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+from __future__ import (absolute_import, division, print_function)
+
+DOCUMENTATION = '''
+---
+module: datasource
+author:
+ - Ishan Jain (@ishanjainn)
+version_added: "0.0.1"
+short_description: Manage Data sources in Grafana Cloud
+description:
+ - Create, Update and delete Data sources using Ansible.
+requirements: [ "requests >= 1.0.0" ]
+notes:
+ - Does not support C(check_mode).
+ - Does not support C(Idempotency).
+options:
+ dataSource:
+ description:
+ - JSON source code for the Data source.
+ type: dict
+ required: true
+ stack_slug:
+ description:
+ - Name of the Grafana Cloud stack to which the data source will be added.
+ type: str
+ required: true
+ grafana_api_key:
+ description:
+ - Grafana API Key to authenticate with Grafana Cloud.
+ type: str
+ required : true
+ state:
+ description:
+ - State for the Grafana Cloud stack.
+ choices: [ present, absent ]
+ default: present
+ type: str
+'''
+
+EXAMPLES = '''
+- name: Create/Update Data sources
+ grafana.grafana.datasource:
+ dataSource: "{{ lookup('ansible.builtin.file', 'datasource.json') }}"
+ stack_slug: "{{ stack_slug }}"
+ grafana_api_key: "{{ grafana_api_key }}"
+ state: present
+
+- name: Delete Data sources
+ grafana.grafana.datasource:
+ dataSource: "{{ lookup('ansible.builtin.file', 'datasource.json') }}"
+ stack_slug: "{{ stack_slug }}"
+ grafana_api_key: "{{ grafana_api_key }}"
+ state: absent
+'''
+
+RETURN = r'''
+output:
+ description: Dict object containing Data source information.
+ returned: On success
+ type: dict
+ contains:
+ datasource:
+ description: The response body content for the data source configuration.
+ returned: state is present and on success
+ type: dict
+ sample: {
+ "access": "proxy",
+ "basicAuth": false,
+ "basicAuthUser": "",
+ "database": "db-name",
+ "id": 20,
+ "isDefault": false,
+ "jsonData": {},
+ "name": "ansible-integration",
+ "orgId": 1,
+ "readOnly": false,
+ "secureJsonFields": {
+ "password": true
+ },
+ "type": "influxdb",
+ "typeLogoUrl": "",
+ "uid": "ansibletest",
+ "url": "https://grafana.github.com/grafana-ansible-collection",
+ "user": "user",
+ "version": 1,
+ "withCredentials": false
+ }
+ id:
+ description: The ID assigned to the data source.
+ returned: on success
+ type: int
+ sample: 20
+ name:
+ description: The name of the data source defined in the JSON source code.
+ returned: state is present and on success
+ type: str
+ sample: "ansible-integration"
+ message:
+ description: The message returned after the operation on the Data source.
+ returned: on success
+ type: str
+ sample: "Datasource added"
+'''
+
+from ansible.module_utils.basic import AnsibleModule, missing_required_lib
+try:
+ import requests
+ HAS_REQUESTS = True
+except ImportError:
+ HAS_REQUESTS = False
+
+__metaclass__ = type
+
+
+def present_datasource(module):
+ api_url = 'https://' + module.params['stack_slug'] + '.grafana.net/api/datasources'
+
+ result = requests.post(api_url, json=module.params['dataSource'], headers={"Authorization": 'Bearer ' + module.params['grafana_api_key']})
+
+ 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['grafana_api_key']})
+
+ api_url = 'https://' + module.params['stack_slug'] + '.grafana.net/api/datasources/' + str(get_id_url.json()['id'])
+
+ result = requests.put(api_url, json=module.params['dataSource'], headers={"Authorization": 'Bearer ' + module.params['grafana_api_key']})
+
+ if result.status_code == 200:
+ return False, True, result.json()
+ else:
+ return True, False, {"status": result.status_code, 'response': result.json()['message']}
+
+ else:
+ return True, False, {"status": result.status_code, 'response': result.json()['message']}
+
+
+def absent_datasource(module):
+ api_url = 'https://' + module.params['stack_slug'] + '.grafana.net/api/datasources/' + module.params['dataSource']['name']
+
+ result = requests.delete(api_url, headers={"Authorization": 'Bearer ' + module.params['grafana_api_key']})
+
+ if result.status_code == 200:
+ return False, True, result.json()
+ else:
+ return True, False, {"status": result.status_code, 'response': result.json()['message']}
+
+
+def main():
+
+ module_args = dict(
+ dataSource=dict(type='dict', required=True),
+ stack_slug=dict(type='str', required=True),
+ grafana_api_key=dict(type='str', required=True, no_log=True),
+ state=dict(type='str', required=False, default='present', choices=['present', 'absent'])
+ )
+
+ choice_map = {
+ "present": present_datasource,
+ "absent": absent_datasource,
+ }
+
+ module = AnsibleModule(
+ argument_spec=module_args
+ )
+
+ if not HAS_REQUESTS:
+ module.fail_json(msg=missing_required_lib('requests'))
+
+ is_error, has_changed, result = choice_map.get(
+ module.params['state'])(module)
+
+ if not is_error:
+ module.exit_json(changed=has_changed, output=result)
+ else:
+ module.fail_json(msg=result)
+
+
+if __name__ == '__main__':
+ main()
diff --git a/ansible_collections/grafana/grafana/plugins/modules/folder.py b/ansible_collections/grafana/grafana/plugins/modules/folder.py
new file mode 100644
index 000000000..165f34f2a
--- /dev/null
+++ b/ansible_collections/grafana/grafana/plugins/modules/folder.py
@@ -0,0 +1,254 @@
+#!/usr/bin/python
+# -*- coding: utf-8 -*-
+
+# Copyright: (c) 2021, Ishan Jain (@ishanjainn)
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+from __future__ import (absolute_import, division, print_function)
+
+DOCUMENTATION = '''
+---
+module: folder
+author:
+ - Ishan Jain (@ishanjainn)
+version_added: "0.0.1"
+short_description: Manage Folders in Grafana Cloud
+description:
+ - Create, Update and delete Folders via Ansible.
+requirements: [ "requests >= 1.0.0" ]
+notes:
+ - Does not support C(check_mode).
+options:
+ title:
+ description:
+ - Sets the title of the folder.
+ type: str
+ required: true
+ uid:
+ description:
+ - Sets the UID for your folder.
+ type: str
+ required: true
+ overwrite:
+ description:
+ - Set to C(false) if you dont want to overwrite existing folder with newer version.
+ type: bool
+ required: false
+ default: true
+ grafana_api_key:
+ description:
+ - Grafana API Key to authenticate with Grafana.
+ type: str
+ required : true
+ stack_slug:
+ description:
+ - Name of the Grafana Cloud stack to which the folder will be added.
+ type: str
+ required: true
+ state:
+ description:
+ - State for the Grafana Cloud stack.
+ choices: [ present, absent ]
+ default: present
+ type: str
+'''
+
+EXAMPLES = '''
+- name: Create/Update a Folder in Grafana
+ grafana.grafana.folder:
+ title: folder_name
+ uid: folder_name
+ overwrite: true
+ stack_slug: "{{ stack_slug }}"
+ grafana_api_key: "{{ grafana_api_key }}"
+ state: present
+
+- name: Delete a Folder in Grafana
+ grafana.grafana.folder:
+ uid: folder_name
+ stack_slug: "{{ stack_slug }}"
+ grafana_api_key: "{{ grafana_api_key }}"
+ state: absent
+'''
+
+RETURN = r'''
+output:
+ description: Dict object containing folder information.
+ returned: On success
+ type: dict
+ contains:
+ canAdmin:
+ description: Boolean value specifying if current user can admin in folder.
+ returned: state is present and on success
+ type: bool
+ sample: true
+ canDelete:
+ description: Boolean value specifying if current user can delete the folder.
+ returned: state is present and on success
+ type: bool
+ sample: true
+ canEdit:
+ description: Boolean value specifying if current user can edit in folder.
+ returned: state is present and on success
+ type: bool
+ sample: true
+ canSave:
+ description: Boolean value specifying if current user can save in folder.
+ returned: state is present and on success
+ type: bool
+ sample: true
+ created:
+ description: The date when folder was created.
+ returned: state is present and on success
+ type: str
+ sample: "2022-10-20T09:31:53Z"
+ createdBy:
+ description: The name of the user who created the folder.
+ returned: state is present and on success
+ type: str
+ sample: "Anonymous"
+ hasAcl:
+ description: Boolean value specifying if folder has acl.
+ returned: state is present and on success
+ type: bool
+ sample: true
+ id:
+ description: The ID for the folder.
+ returned: state is present and on success
+ type: int
+ sample: 18
+ title:
+ description: The name of the folder.
+ returned: on success
+ type: str
+ sample: foldername
+ uid:
+ description: The UID for the folder.
+ returned: state is present and on success
+ type: str
+ sample: foldername
+ updated:
+ description: The date when the folder was last updated.
+ returned: state is present and on success
+ type: str
+ sample: "2022-10-20T09:31:53Z"
+ updatedBy:
+ description: The name of the user who last updated the folder.
+ returned: state is present and on success
+ type: str
+ sample: "Anonymous"
+ url:
+ description: The URl for the folder.
+ returned: state is present and on success
+ type: str
+ sample: "/dashboards/f/foldername/foldername"
+ version:
+ description: The version of the folder.
+ returned: state is present and on success
+ type: int
+ sample: 1
+ message:
+ description: The message returned after the operation on the folder.
+ returned: state is absent and on success
+ type: str
+ sample: "Folder has been succesfuly deleted"
+'''
+
+from ansible.module_utils.basic import AnsibleModule, missing_required_lib
+try:
+ import requests
+ HAS_REQUESTS = True
+except ImportError:
+ HAS_REQUESTS = False
+
+__metaclass__ = type
+
+
+def present_folder(module):
+ body = {
+ 'uid': module.params['uid'],
+ 'title': module.params['title'],
+ }
+ api_url = 'https://' + module.params['stack_slug'] + '.grafana.net/api/folders'
+
+ result = requests.post(api_url, json=body, headers={"Authorization": 'Bearer ' + module.params['grafana_api_key']})
+
+ if result.status_code == 200:
+ return False, True, result.json()
+ elif result.status_code == 412:
+ sameConfig = False
+ folderInfo = {}
+
+ api_url = 'https://' + module.params['stack_slug'] + '.grafana.net/api/folders'
+ result = requests.get(api_url, headers={"Authorization": 'Bearer ' + module.params['grafana_api_key']})
+
+ for folder in result.json():
+ if folder['uid'] == module.params['uid'] and folder['title'] == module.params['title']:
+ sameConfig = True
+ folderInfo = folder
+
+ if sameConfig:
+ return False, False, folderInfo
+ else:
+ body = {
+ 'uid': module.params['uid'],
+ 'title': module.params['title'],
+ 'overwrite': module.params['overwrite']
+ }
+ api_url = 'https://' + module.params['stack_slug'] + '.grafana.net/api/folders/' + module.params['uid']
+
+ result = requests.put(api_url, json=body, headers={"Authorization": 'Bearer ' + module.params['grafana_api_key']})
+
+ if result.status_code == 200:
+ return False, True, result.json()
+ else:
+ return True, False, {"status": result.status_code, 'response': result.json()['message']}
+ else:
+ return True, False, {"status": result.status_code, 'response': result.json()['message']}
+
+
+def absent_folder(module):
+ api_url = 'https://' + module.params['stack_slug'] + '.grafana.net/api/folders/' + module.params['uid']
+
+ result = requests.delete(api_url, headers={"Authorization": 'Bearer ' + module.params['grafana_api_key']})
+
+ if result.status_code == 200:
+ return False, True, {"status": result.status_code, 'response': "Folder has been succesfuly deleted"}
+ else:
+ return True, False, {"status": result.status_code, 'response': "Error deleting folder"}
+
+
+def main():
+
+ module_args = dict(
+ title=dict(type='str', required=True),
+ uid=dict(type='str', required=True),
+ overwrite=dict(type='bool', required=False, default=True),
+ stack_slug=dict(type='str', required=True),
+ grafana_api_key=dict(type='str', required=True, no_log=True),
+ state=dict(type='str', required=False, default='present', choices=['present', 'absent'])
+ )
+
+ choice_map = {
+ "present": present_folder,
+ "absent": absent_folder,
+ }
+
+ module = AnsibleModule(
+ argument_spec=module_args
+ )
+
+ if not HAS_REQUESTS:
+ module.fail_json(msg=missing_required_lib('requests'))
+
+ is_error, has_changed, result = choice_map.get(
+ module.params['state'])(module)
+
+ if not is_error:
+ module.exit_json(changed=has_changed, output=result)
+ else:
+ module.fail_json(msg=result)
+
+
+if __name__ == '__main__':
+ main()
diff --git a/ansible_collections/grafana/grafana/roles/grafana_agent/README.md b/ansible_collections/grafana/grafana/roles/grafana_agent/README.md
new file mode 100644
index 000000000..8f9d39a6a
--- /dev/null
+++ b/ansible_collections/grafana/grafana/roles/grafana_agent/README.md
@@ -0,0 +1,54 @@
+Role Name
+=========
+
+Ansible Role to deploy Grafana Agent on Linux hosts. Using this Role, Grafana Agent can be deployed on Ubunutu, Debian, CentOS and Fedora linux distributions
+
+
+Requirements
+------------
+
+To use this role, You need a YAML file having the Grafana Agent configuration
+
+Role Variables
+--------------
+
+A description of the variables for this role.
+
+| Variable | Required | Default | Choices | Comments |
+|-------------------------|----------|----------------------|--------------------------------------------------------------------------------------------------------------------|---------------------------------------------|
+| install_unzip | no | true | true, false | This will install unzip on the Linux host |
+| update_package_cache | no | yes | yes, no | Force dnf/apt to check if cache is out of date and redownload if needed.|
+| agent_version | no | 0.29.0 | 0.29.0, 0.28.1, 0.28.0, 0.27.1, 0.27.0 | Version of the Grafana agent to install|
+| linux_architecture | no | linux-amd64 | linux-amd64, linux-arm64, linux-armv6, linux-armv7, linux-ppc64le | Type of linux architecture of the remote host|
+| agent_binary_location | no | /usr/local/bin | | Path where the agent binary will be copied to on the remote host|
+| agent_config_location | no | /etc/grafana | | Path where the agent configuration will be copied to on the remote host|
+| agent_config_local_path | yes | agent-config.yml | | Path to the agent configuration file on local|
+| systemd_service_state | no | restarted | reloaded, restarted, started, stopped | Operation performed on the systemd service|
+| systemd_config | no | | | Configuration for grafana-agent systemd service|
+
+Example Playbook
+----------------
+
+Including an example of how to use your role (for instance, with variables passed in as parameters) is always nice for users too:
+
+```yaml
+- name: Install Grafana Agent
+ hosts: all
+
+ tasks:
+ - name: Install Grafana Agent
+ ansible.builtin.include_role:
+ name: grafana.grafana.grafana_agent:
+ vars:
+ agent_config_local_path: ../agent-config.yml
+```
+License
+-------
+
+See [LICENSE](https://github.com/grafana/grafana-ansible-collection/blob/main/LICENSE)
+
+Author Information
+------------------
+- [Grafana Labs](https://github.com/grafana)
+- [Ishan Jain](https://github.com/ishanjainn)
+
diff --git a/ansible_collections/grafana/grafana/roles/grafana_agent/defaults/main.yml b/ansible_collections/grafana/grafana/roles/grafana_agent/defaults/main.yml
new file mode 100644
index 000000000..13a060e03
--- /dev/null
+++ b/ansible_collections/grafana/grafana/roles/grafana_agent/defaults/main.yml
@@ -0,0 +1,20 @@
+install_unzip: true
+update_package_cache: yes
+agent_version: 0.29.0
+linux_architecture: linux-amd64
+agent_binary_location: /usr/local/bin
+agent_config_location: /etc/grafana
+agent_config_local_path: agent-config.yml
+
+systemd_service_state: restarted
+systemd_config: |
+ [Unit]
+ Description=Grafana Agent
+
+ [Service]
+ User=grafana-agent
+ ExecStart={{ agent_binary_location }}/agent-{{ linux_architecture }} --config.file={{ agent_config_location }}/agent-config.yaml
+ Restart=always
+
+ [Install]
+ WantedBy=multi-user.target \ No newline at end of file
diff --git a/ansible_collections/grafana/grafana/roles/grafana_agent/meta/main.yml b/ansible_collections/grafana/grafana/roles/grafana_agent/meta/main.yml
new file mode 100644
index 000000000..c99271d78
--- /dev/null
+++ b/ansible_collections/grafana/grafana/roles/grafana_agent/meta/main.yml
@@ -0,0 +1,25 @@
+---
+dependencies: []
+
+galaxy_info:
+ role_name: grafana_agent
+ author: Ishan Jain
+ description: Ansible Role to deploy Grafana Agent on Linux hosts.
+ license: "GPL-3.0-or-later"
+ min_ansible_version: "2.11"
+ platforms:
+ - name: Fedora
+ versions:
+ - "all"
+ - name: Debian
+ versions:
+ - "all"
+ - name: Ubuntu
+ versions:
+ - "all"
+ - name: EL
+ versions:
+ - "all"
+ galaxy_tags:
+ - grafana
+ - observability \ No newline at end of file
diff --git a/ansible_collections/grafana/grafana/roles/grafana_agent/tasks/main.yml b/ansible_collections/grafana/grafana/roles/grafana_agent/tasks/main.yml
new file mode 100644
index 000000000..0c5752c3b
--- /dev/null
+++ b/ansible_collections/grafana/grafana/roles/grafana_agent/tasks/main.yml
@@ -0,0 +1,59 @@
+- name: Install unzip on Ubuntu/Debian
+ ansible.builtin.apt:
+ name: unzip
+ state: present
+ update_cache: "{{ update_package_cache }}"
+ when: install_unzip | bool and (ansible_distribution == "Ubuntu" or ansible_distribution == "Debian")
+
+- name: Install unzip on Fedora/CentOS
+ ansible.builtin.dnf:
+ name: unzip
+ state: latest
+ update_cache: "{{ update_package_cache }}"
+ when: install_unzip | bool and (ansible_distribution == "Fedora" or ansible_distribution == "CentOS")
+
+- name: Download Grafana Agent binary from GitHub
+ ansible.builtin.get_url:
+ url: "https://github.com/grafana/agent/releases/download/v{{ agent_version }}/agent-{{ linux_architecture }}.zip"
+ dest: "/tmp/agent-linux.zip"
+ mode: '0644'
+
+- name: Unarchive the Grafana Agent binary
+ ansible.builtin.unarchive:
+ src: "/tmp/agent-linux.zip"
+ dest: "{{ agent_binary_location }}"
+ remote_src: yes
+ mode: '0755'
+
+- name: Create directory for Grafana Agent Configuration file
+ ansible.builtin.file:
+ path: "{{ agent_config_location }}"
+ state: directory
+ mode: '0755'
+
+- name: Create configuration file for Grafana Agent
+ ansible.builtin.copy:
+ src: "{{ agent_config_local_path }}"
+ dest: "{{ agent_config_location }}/agent-config.yaml"
+
+- name: Add user 'grafana-agent'
+ ansible.builtin.user:
+ name: grafana-agent
+ create_home: no
+ shell: /bin/false
+
+- name: Create service file for Grafana Agent
+ ansible.builtin.copy:
+ dest: "/etc/systemd/system/grafana-agent.service"
+ content: "{{ systemd_config }}"
+
+- name: Start Grafana Agent service
+ ansible.builtin.systemd:
+ daemon_reload: yes
+ name: grafana-agent
+ enabled: yes
+ state: "{{ systemd_service_state }}"
+
+- name: Checking grafana-agent service status
+ ansible.builtin.shell:
+ cmd: systemctl is-active grafana-agent \ No newline at end of file
diff --git a/ansible_collections/grafana/grafana/tests/integration/requirements.txt b/ansible_collections/grafana/grafana/tests/integration/requirements.txt
new file mode 100644
index 000000000..663bd1f6a
--- /dev/null
+++ b/ansible_collections/grafana/grafana/tests/integration/requirements.txt
@@ -0,0 +1 @@
+requests \ No newline at end of file
diff --git a/ansible_collections/grafana/grafana/tests/integration/targets/alert_contact_point/tasks/main.yml b/ansible_collections/grafana/grafana/tests/integration/targets/alert_contact_point/tasks/main.yml
new file mode 100644
index 000000000..c6727fa63
--- /dev/null
+++ b/ansible_collections/grafana/grafana/tests/integration/targets/alert_contact_point/tasks/main.yml
@@ -0,0 +1,71 @@
+- name: Create Alerting contact point
+ grafana.grafana.alert_contact_point:
+ name: ops-email
+ uid: opsemail
+ type: email
+ settings: {
+ addresses: "ops@mydomain.com,devs@mydomain.com"
+ }
+ stack_slug: "{{ stack_name }}"
+ grafana_api_key: "{{ grafana_api_key }}"
+ state: present
+ register: add_result
+
+- assert:
+ that:
+ - add_result.failed == false
+ - add_result.output.provenance == "api"
+
+- name: Idempotency Check
+ grafana.grafana.alert_contact_point:
+ name: ops-email
+ uid: opsemail
+ type: email
+ settings: {
+ addresses: "ops@mydomain.com,devs@mydomain.com"
+ }
+ stack_slug: "{{ stack_name }}"
+ grafana_api_key: "{{ grafana_api_key }}"
+ state: present
+ register: idempotent_result
+
+- assert:
+ that:
+ - idempotent_result.changed == false
+ - idempotent_result.output.provenance == "api"
+
+- name: Update Alerting contact point
+ grafana.grafana.alert_contact_point:
+ name: ops-email
+ uid: opsemail
+ type: email
+ settings: {
+ addresses: "ops@mydomain.com,devs@mydomain.com,admin@mydomain.com"
+ }
+ stack_slug: "{{ stack_name }}"
+ grafana_api_key: "{{ grafana_api_key }}"
+ state: present
+ register: update_result
+
+- assert:
+ that:
+ - update_result.failed == false
+ - update_result.output.provenance == "api"
+
+- name: Delete Alerting contact point
+ grafana.grafana.alert_contact_point:
+ name: ops-email
+ uid: opsemail
+ type: email
+ settings: {
+ addresses: "ops@mydomain.com,devs@mydomain.com,admin@mydomain.com"
+ }
+ stack_slug: "{{ stack_name }}"
+ grafana_api_key: "{{ grafana_api_key }}"
+ state: absent
+ register: delete_result
+
+- assert:
+ that:
+ - delete_result.failed == false
+ - delete_result.output.message == "contactpoint deleted" \ No newline at end of file
diff --git a/ansible_collections/grafana/grafana/tests/integration/targets/alert_notification_policy/tasks/main.yml b/ansible_collections/grafana/grafana/tests/integration/targets/alert_notification_policy/tasks/main.yml
new file mode 100644
index 000000000..681ff53a5
--- /dev/null
+++ b/ansible_collections/grafana/grafana/tests/integration/targets/alert_notification_policy/tasks/main.yml
@@ -0,0 +1,16 @@
+- name: Set Notification policy tree
+ grafana.grafana.alert_notification_policy:
+ stack_slug: "{{ stack_name }}"
+ grafana_api_key: "{{ grafana_api_key }}"
+ routes: [
+ {
+ receiver: grafana-default-email,
+ object_matchers: [["env", "=", "Production"]],
+ }
+ ]
+ register: result
+
+- assert:
+ that:
+ - result.failed == false
+ - result.output.provenance == "api" \ No newline at end of file
diff --git a/ansible_collections/grafana/grafana/tests/integration/targets/cloud_api_key/tasks/main.yml b/ansible_collections/grafana/grafana/tests/integration/targets/cloud_api_key/tasks/main.yml
new file mode 100644
index 000000000..86c3fcfc5
--- /dev/null
+++ b/ansible_collections/grafana/grafana/tests/integration/targets/cloud_api_key/tasks/main.yml
@@ -0,0 +1,43 @@
+- name: Create Grafana Cloud API key
+ grafana.grafana.cloud_api_key:
+ name: ansible-integration-test
+ role: Admin
+ org_slug: "{{ org_name }}"
+ existing_cloud_api_key: "{{ grafana_cloud_api_key }}"
+ fail_if_already_created: False
+ state: present
+ register: add_result
+
+- assert:
+ that:
+ - add_result.output.name == "ansible-integration-test"
+ when: add_result.output.name is defined
+
+- name: Re-run previous task
+ grafana.grafana.cloud_api_key:
+ name: ansible-integration-test
+ role: Admin
+ org_slug: "{{ org_name }}"
+ existing_cloud_api_key: "{{ grafana_cloud_api_key }}"
+ fail_if_already_created: False
+ state: present
+ register: update_result
+
+- assert:
+ that:
+ - update_result.changed == false
+ - update_result.output == "A Cloud API key with the same name already exists"
+
+- name: Delete Grafana Cloud API key
+ grafana.grafana.cloud_api_key:
+ name: ansible-integration-test
+ role: Admin
+ org_slug: "{{ org_name }}"
+ existing_cloud_api_key: "{{ grafana_cloud_api_key }}"
+ state: absent
+ register: delete_result
+
+- assert:
+ that:
+ - delete_result.changed == true
+ - delete_result.output == "Cloud API key is deleted"
diff --git a/ansible_collections/grafana/grafana/tests/integration/targets/cloud_plugin/tasks/main.yml b/ansible_collections/grafana/grafana/tests/integration/targets/cloud_plugin/tasks/main.yml
new file mode 100644
index 000000000..125de8025
--- /dev/null
+++ b/ansible_collections/grafana/grafana/tests/integration/targets/cloud_plugin/tasks/main.yml
@@ -0,0 +1,55 @@
+- name: Add a plugin
+ grafana.grafana.cloud_plugin:
+ name: grafana-github-datasource
+ version: 1.0.14
+ stack_slug: "{{ stack_name }}"
+ cloud_api_key: "{{ grafana_cloud_api_key }}"
+ state: present
+ register: add_result
+
+- assert:
+ that:
+ - add_result.changed == true
+ - add_result.pluginName == "GitHub"
+
+- name: Idempotency Check
+ grafana.grafana.cloud_plugin:
+ name: grafana-github-datasource
+ version: 1.0.14
+ stack_slug: "{{ stack_name }}"
+ cloud_api_key: "{{ grafana_cloud_api_key }}"
+ state: present
+ register: idempotency_result
+
+- assert:
+ that:
+ - idempotency_result.changed == false
+ - idempotency_result.pluginName == "GitHub"
+
+- name: Update a plugin
+ grafana.grafana.cloud_plugin:
+ name: grafana-github-datasource
+ version: 1.0.15
+ stack_slug: "{{ stack_name }}"
+ cloud_api_key: "{{ grafana_cloud_api_key }}"
+ state: present
+ register: update_result
+
+- assert:
+ that:
+ - update_result.changed == true
+ - update_result.pluginName == "GitHub"
+
+- name: Delete a plugin
+ grafana.grafana.cloud_plugin:
+ name: grafana-github-datasource
+ version: 1.0.15
+ stack_slug: "{{ stack_name }}"
+ cloud_api_key: "{{ grafana_cloud_api_key }}"
+ state: absent
+ register: delete_result
+
+- assert:
+ that:
+ - delete_result.changed == true
+ - delete_result.pluginName == "GitHub" \ No newline at end of file
diff --git a/ansible_collections/grafana/grafana/tests/integration/targets/cloud_stack/tasks/main.yml b/ansible_collections/grafana/grafana/tests/integration/targets/cloud_stack/tasks/main.yml
new file mode 100644
index 000000000..861624bf0
--- /dev/null
+++ b/ansible_collections/grafana/grafana/tests/integration/targets/cloud_stack/tasks/main.yml
@@ -0,0 +1,30 @@
+- name: Create a Grafana Cloud stack
+ grafana.grafana.cloud_stack:
+ name: "{{ test_stack_name }}"
+ stack_slug: "{{ test_stack_name }}"
+ cloud_api_key: "{{ grafana_cloud_api_key }}"
+ org_slug: "{{ org_name }}"
+ state: present
+ register: create_result
+
+- assert:
+ that:
+ - create_result.url == "https://" + "{{ test_stack_name }}" + ".grafana.net"
+
+- name: Sleep for 30 seconds
+ ansible.builtin.wait_for:
+ timeout: 30
+
+- name: Delete a Grafana Cloud stack
+ grafana.grafana.cloud_stack:
+ name: "{{ test_stack_name }}"
+ stack_slug: "{{ test_stack_name }}"
+ cloud_api_key: "{{ grafana_cloud_api_key }}"
+ org_slug: "{{ org_name }}"
+ state: absent
+ register: delete_result
+
+- assert:
+ that:
+ - delete_result.changed == true
+ - delete_result.url == "https://" + "{{ test_stack_name }}" + ".grafana.net"
diff --git a/ansible_collections/grafana/grafana/tests/integration/targets/dashboard/tasks/main.yml b/ansible_collections/grafana/grafana/tests/integration/targets/dashboard/tasks/main.yml
new file mode 100644
index 000000000..242a2883c
--- /dev/null
+++ b/ansible_collections/grafana/grafana/tests/integration/targets/dashboard/tasks/main.yml
@@ -0,0 +1,47 @@
+- name: Create/Update a dashboard
+ grafana.grafana.dashboard:
+ dashboard: {
+ "dashboard": {
+ "uid": test1234,
+ "title": "Ansible Integration Test",
+ "tags": [ "templated" ],
+ "timezone": "browser",
+ "schemaVersion": 16,
+ "version": 0,
+ "refresh": "25s"
+ },
+ "overwrite": true
+ }
+ stack_slug: "{{ stack_name }}"
+ grafana_api_key: "{{ grafana_api_key }}"
+ state: present
+ register: result_present
+
+- assert:
+ that:
+ - result_present.changed == true
+ - result_present.output.status == "success"
+
+- name: Delete dashboard
+ grafana.grafana.dashboard:
+ dashboard: {
+ "dashboard": {
+ "uid": test1234,
+ "title": "Ansible Integration Test",
+ "tags": [ "templated" ],
+ "timezone": "browser",
+ "schemaVersion": 16,
+ "version": 0,
+ "refresh": "25s"
+ },
+ "overwrite": true
+ }
+ stack_slug: "{{ stack_name }}"
+ grafana_api_key: "{{ grafana_api_key }}"
+ state: absent
+ register: result_absent
+
+- assert:
+ that:
+ - result_absent.changed == true
+ - result_absent.output.message == "Dashboard Ansible Integration Test deleted" \ No newline at end of file
diff --git a/ansible_collections/grafana/grafana/tests/integration/targets/datasource/tasks/main.yml b/ansible_collections/grafana/grafana/tests/integration/targets/datasource/tasks/main.yml
new file mode 100644
index 000000000..1925b4778
--- /dev/null
+++ b/ansible_collections/grafana/grafana/tests/integration/targets/datasource/tasks/main.yml
@@ -0,0 +1,23 @@
+- name: Create/Update a Data Source
+ grafana.grafana.datasource:
+ dataSource: {
+ name: "ansible-integration",
+ type: "influxdb",
+ url: "https://grafana.github.com/grafana-ansible-collection",
+ user: "user",
+ secureJsonData:
+ { password: "password" },
+ database: "db-name",
+ id: 123,
+ uid: "ansibletest",
+ access: "proxy"
+ }
+ stack_slug: "{{ stack_name }}"
+ grafana_api_key: "{{ grafana_api_key }}"
+ state: present
+ register: create_result
+
+- assert:
+ that:
+ - create_result.changed == true
+ - create_result.output.message == "Datasource added" or create_result.output.message == "Datasource updated" \ No newline at end of file
diff --git a/ansible_collections/grafana/grafana/tests/integration/targets/folder/tasks/main.yml b/ansible_collections/grafana/grafana/tests/integration/targets/folder/tasks/main.yml
new file mode 100644
index 000000000..452aca67e
--- /dev/null
+++ b/ansible_collections/grafana/grafana/tests/integration/targets/folder/tasks/main.yml
@@ -0,0 +1,28 @@
+- name: Create/Update a Folder in Grafana
+ grafana.grafana.folder:
+ title: Ansible Integration test
+ uid: test123
+ overwrite: true
+ stack_slug: "{{ stack_name }}"
+ grafana_api_key: "{{ grafana_api_key }}"
+ state: present
+ register: create_result
+
+- assert:
+ that:
+ - create_result.failed == false
+
+- name: Delete a folder
+ grafana.grafana.folder:
+ title: Ansible Integration test
+ uid: test123
+ overwrite: true
+ stack_slug: "{{ stack_name }}"
+ grafana_api_key: "{{ grafana_api_key }}"
+ state: absent
+ register: delete_result
+
+- assert:
+ that:
+ - delete_result.output.status == 200
+ - delete_result.output.response == "Folder has been succesfuly deleted"