diff --git a/.github/settings.yml b/.github/settings.yml index 9fde967c..6c29d5cb 100644 --- a/.github/settings.yml +++ b/.github/settings.yml @@ -1,3 +1,4 @@ +--- ### # https://probot.github.io/apps/settings/ # @@ -5,9 +6,6 @@ # DO NOT MODIFY # this is a copy of https://github.com/gundalow-collection/.github/blob/master/.github/settings.yml # Work around till https://github.com/probot/settings/pull/179 is merged - - - repository: # See https://developer.github.com/v3/repos/#edit for all available settings. has_issues: true @@ -25,7 +23,7 @@ labels: description: This issue/PR relates to a bug. - name: feature description: This issue/PR relates to a feature request. - color: 006b75 + color: "006b75" - name: migrated_from_ansible_ansible color: 5319e7 description: This issue/PR was moved from gh/ansible/ansible diff --git a/.github/workflows/ansible-test.yml b/.github/workflows/ansible-test.yml index 85fbc432..e1ef3a93 100644 --- a/.github/workflows/ansible-test.yml +++ b/.github/workflows/ansible-test.yml @@ -1,10 +1,10 @@ +--- name: CI on: push: branches: - main pull_request: - jobs: sanity: runs-on: ubuntu-latest @@ -13,7 +13,7 @@ jobs: strategy: matrix: python_version: ["3.10"] - ansible_version: ["stable-2.13", "stable-2.14", "devel"] + ansible_version: [stable-2.13, stable-2.14, devel] steps: - name: Perform testing uses: ansible-community/ansible-test-gh-action@release/v1 @@ -30,7 +30,7 @@ jobs: strategy: matrix: python_version: ["3.10"] - ansible_version: ["stable-2.13", "stable-2.14", "devel"] + ansible_version: [stable-2.13, stable-2.14, devel] steps: - name: Perform testing uses: ansible-community/ansible-test-gh-action@release/v1 @@ -45,8 +45,8 @@ jobs: strategy: fail-fast: false matrix: - grafana_version: ["9.5.14", "8.5.27", "10.2.2"] - ansible_version: ["stable-2.13", "stable-2.14", "devel"] + grafana_version: [9.5.14, 8.5.27, 10.2.2] + ansible_version: [stable-2.13, stable-2.14, devel] python_version: ["3.10"] services: grafana: diff --git a/.github/workflows/check_grafana_releases.yml b/.github/workflows/check_grafana_releases.yml index e3fd3b02..2edf8140 100644 --- a/.github/workflows/check_grafana_releases.yml +++ b/.github/workflows/check_grafana_releases.yml @@ -1,8 +1,9 @@ +--- name: Check Grafana Releases on: schedule: - - cron: '0 1 * * 0' + - cron: "0 1 * * 0" permissions: contents: read @@ -12,7 +13,6 @@ jobs: check_grafana_releases: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - name: Set up Python ${{ matrix.python_version }} @@ -29,9 +29,9 @@ jobs: - name: Create Pull Request uses: peter-evans/create-pull-request@v4 with: - token: ${{ secrets.RREY_PAT }} - commit-message: Update tested Grafana versions - title: Bump Grafana versions - branch: auto-bump-grafana - reviewers: rrey - base: main + token: ${{ secrets.RREY_PAT }} + commit-message: Update tested Grafana versions + title: Bump Grafana versions + branch: auto-bump-grafana + reviewers: rrey + base: main diff --git a/.github/workflows/fragment.yml b/.github/workflows/fragment.yml index 3e1ebe73..a3afa73b 100644 --- a/.github/workflows/fragment.yml +++ b/.github/workflows/fragment.yml @@ -1,18 +1,17 @@ --- -on: +on: pull_request: - name: Check changelog fragment jobs: check_fragment: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - with: - fetch-depth: 0 + - uses: actions/checkout@v2 + with: + fetch-depth: 0 - - name: Check that changelog fragment exists - run: ./hacking/check_fragment.sh - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - PR_NUMBER: ${{ github.event.number }} + - name: Check that changelog fragment exists + run: ./hacking/check_fragment.sh + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + PR_NUMBER: ${{ github.event.number }} diff --git a/.github/workflows/rebase.yml b/.github/workflows/rebase.yml index 2b3e81c5..c2b6c4e6 100644 --- a/.github/workflows/rebase.yml +++ b/.github/workflows/rebase.yml @@ -1,6 +1,7 @@ +--- # https://github.com/marketplace/actions/automatic-rebase # GitHub Actions don't automatically rebase before running, so add support for people to type `/rebase` -on: +on: issue_comment: types: [created] name: Automatic Rebase @@ -10,11 +11,11 @@ jobs: if: github.event.issue.pull_request != '' && contains(github.event.comment.body, '/rebase') runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - name: Automatic Rebase - uses: cirrus-actions/rebase@1.6 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - uses: actions/checkout@v2 + - name: Automatic Rebase + uses: cirrus-actions/rebase@1.6 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # https://github.community/t5/GitHub-Actions/Workflow-is-failing-if-no-job-can-be-ran-due-to-condition/m-p/38186#M3250 always_job: name: Aways run job diff --git a/changelogs/fragments/326_linting.yml b/changelogs/fragments/326_linting.yml new file mode 100644 index 00000000..e0124934 --- /dev/null +++ b/changelogs/fragments/326_linting.yml @@ -0,0 +1,2 @@ +minor_changes: + - run ansible-lint on yaml files diff --git a/codecov.yml b/codecov.yml index c01a21d4..2bd42e7e 100644 --- a/codecov.yml +++ b/codecov.yml @@ -1,6 +1,7 @@ +--- coverage: precision: 2 round: down - range: "70...100" + range: 70...100 fixes: - - "/ansible_collections/community/grafana/::" + - "/ansible_collections/community/grafana/::" diff --git a/galaxy.yml b/galaxy.yml index 739c4c33..dbfb2d93 100644 --- a/galaxy.yml +++ b/galaxy.yml @@ -1,3 +1,4 @@ +--- namespace: community name: grafana version: 1.6.1 diff --git a/meta/runtime.yml b/meta/runtime.yml index ed9ac426..06ab11f5 100644 --- a/meta/runtime.yml +++ b/meta/runtime.yml @@ -1,5 +1,5 @@ --- -requires_ansible: '>=2.9.0' +requires_ansible: ">=2.9.0" action_groups: grafana: - grafana_dashboard diff --git a/tests/integration/targets/grafana_dashboard/defaults/main.yml b/tests/integration/targets/grafana_dashboard/defaults/main.yml index 8b9c9348..4abf9bb4 100644 --- a/tests/integration/targets/grafana_dashboard/defaults/main.yml +++ b/tests/integration/targets/grafana_dashboard/defaults/main.yml @@ -1,7 +1,5 @@ --- -grafana_url: "http://grafana:3000/" -grafana_username: "admin" -grafana_password: "admin" - -... +grafana_url: http://grafana:3000/ +grafana_username: admin +grafana_password: admin diff --git a/tests/integration/targets/grafana_dashboard/tasks/dashboard-export.yml b/tests/integration/targets/grafana_dashboard/tasks/dashboard-export.yml index 04b17f72..60c4a7b1 100644 --- a/tests/integration/targets/grafana_dashboard/tasks/dashboard-export.yml +++ b/tests/integration/targets/grafana_dashboard/tasks/dashboard-export.yml @@ -1,9 +1,9 @@ --- -- set_fact: +- ansible.builtin.set_fact: dashboard_uid: "{{ result.uid }}" - name: Check export grafana dashboard to file - grafana_dashboard: + community.grafana.grafana_dashboard: grafana_url: "{{ grafana_url }}" grafana_user: "{{ grafana_username }}" grafana_password: "{{ grafana_password }}" @@ -13,21 +13,21 @@ uid: "{{ dashboard_uid }}" register: result -- debug: +- ansible.builtin.debug: var: result -- assert: +- ansible.builtin.assert: that: - - "result.changed == true" - - "result.msg == 'Dashboard {{ dashboard_uid }} exported to /tmp/dashboard.json'" + - result.changed == true + - result.msg == 'Dashboard {{ dashboard_uid }} exported to /tmp/dashboard.json' - name: Load /tmp/dashboard.json or fail if missing - set_fact: + ansible.builtin.set_fact: exported_dashboard_lines: "{{ lookup('file', '/tmp/dashboard.json').splitlines() }}" - name: Assert that exported dashboard contains formatted JSON - assert: + ansible.builtin.assert: that: - - "exported_dashboard_lines | length >= 2" - - "exported_dashboard_lines[0] == '{'" - - "exported_dashboard_lines[-1] == '}'" + - exported_dashboard_lines | length >= 2 + - exported_dashboard_lines[0] == '{' + - exported_dashboard_lines[-1] == '}' diff --git a/tests/integration/targets/grafana_dashboard/tasks/dashboard-folder-destination.yml b/tests/integration/targets/grafana_dashboard/tasks/dashboard-folder-destination.yml index f4f3d9f4..ea23daee 100644 --- a/tests/integration/targets/grafana_dashboard/tasks/dashboard-folder-destination.yml +++ b/tests/integration/targets/grafana_dashboard/tasks/dashboard-folder-destination.yml @@ -1,33 +1,33 @@ --- -- name: copy dashboard file - copy: - src: "files/dashboard.json" - dest: "/tmp/dashboard.json" +- name: Copy dashboard file + ansible.builtin.copy: + src: files/dashboard.json + dest: /tmp/dashboard.json - block: - - name: Check import grafana dashboard from file to unknown folder fails - grafana_dashboard: - grafana_url: "{{ grafana_url }}" - grafana_user: "{{ grafana_username }}" - grafana_password: "{{ grafana_password }}" - state: present - commit_message: Updated by ansible - path: /tmp/dashboard.json - overwrite: true - folder: inexistent - register: result - ignore_errors: true + - name: Check import grafana dashboard from file to unknown folder fails + community.grafana.grafana_dashboard: + grafana_url: "{{ grafana_url }}" + grafana_user: "{{ grafana_username }}" + grafana_password: "{{ grafana_password }}" + state: present + commit_message: Updated by ansible + path: /tmp/dashboard.json + overwrite: true + folder: inexistent + register: result + ignore_errors: true -- debug: +- ansible.builtin.debug: var: result -- set_fact: +- ansible.builtin.set_fact: # XXX: Too many quotes of different types to do inline. # I did not manage to find a good way of having it inline. expected_error: "error : Dashboard folder 'inexistent' does not exist." -- assert: +- ansible.builtin.assert: that: - - "result.changed == false" - - "result.failed == true" - - "result.msg == expected_error" + - result.changed == false + - result.failed == true + - result.msg == expected_error diff --git a/tests/integration/targets/grafana_dashboard/tasks/dashboard-from-file.yml b/tests/integration/targets/grafana_dashboard/tasks/dashboard-from-file.yml index 93df1666..efbfb4cf 100644 --- a/tests/integration/targets/grafana_dashboard/tasks/dashboard-from-file.yml +++ b/tests/integration/targets/grafana_dashboard/tasks/dashboard-from-file.yml @@ -1,12 +1,11 @@ --- -- name: copy dashboard file - copy: - src: "files/dashboard.json" - dest: "/tmp/dashboard.json" - +- name: Copy dashboard file + ansible.builtin.copy: + src: files/dashboard.json + dest: /tmp/dashboard.json - name: Check import grafana dashboard from file - grafana_dashboard: + community.grafana.grafana_dashboard: grafana_url: "{{ grafana_url }}" grafana_user: "{{ grafana_username }}" grafana_password: "{{ grafana_password }}" @@ -16,16 +15,16 @@ overwrite: true register: result -- debug: +- ansible.builtin.debug: var: result -- assert: +- ansible.builtin.assert: that: - - "result.changed == true" - - "result.msg == 'Dashboard test created'" + - result.changed == true + - result.msg == 'Dashboard test created' - name: Check import grafana dashboard from file idempotency - grafana_dashboard: + community.grafana.grafana_dashboard: grafana_url: "{{ grafana_url }}" grafana_user: "{{ grafana_username }}" grafana_password: "{{ grafana_password }}" @@ -35,10 +34,10 @@ overwrite: true register: result -- debug: +- ansible.builtin.debug: var: result -- assert: +- ansible.builtin.assert: that: - - "result.changed == false" - - "result.msg == 'Dashboard test unchanged.'" + - result.changed == false + - result.msg == 'Dashboard test unchanged.' diff --git a/tests/integration/targets/grafana_dashboard/tasks/dashboard-from-id.yml b/tests/integration/targets/grafana_dashboard/tasks/dashboard-from-id.yml index 3b81ebf7..d755e4b2 100644 --- a/tests/integration/targets/grafana_dashboard/tasks/dashboard-from-id.yml +++ b/tests/integration/targets/grafana_dashboard/tasks/dashboard-from-id.yml @@ -1,6 +1,6 @@ --- - name: Check import grafana dashboard from id - grafana_dashboard: + community.grafana.grafana_dashboard: grafana_url: "{{ grafana_url }}" grafana_user: "{{ grafana_username }}" grafana_password: "{{ grafana_password }}" @@ -11,16 +11,16 @@ overwrite: true register: result -- debug: +- ansible.builtin.debug: var: result -- assert: +- ansible.builtin.assert: that: - - "result.changed == true" - - "result.msg == 'Dashboard Zabbix Host Status created'" + - result.changed == true + - result.msg == 'Dashboard Zabbix Host Status created' - name: Check import grafana dashboard from id idempotency - grafana_dashboard: + community.grafana.grafana_dashboard: grafana_url: "{{ grafana_url }}" grafana_user: "{{ grafana_username }}" grafana_password: "{{ grafana_password }}" @@ -31,10 +31,10 @@ overwrite: true register: result -- debug: +- ansible.builtin.debug: var: result -- assert: +- ansible.builtin.assert: that: - - "result.changed == false" - - "result.msg == 'Dashboard Zabbix Host Status unchanged.'" + - result.changed == false + - result.msg == 'Dashboard Zabbix Host Status unchanged.' diff --git a/tests/integration/targets/grafana_dashboard/tasks/dashboard-from-url.yml b/tests/integration/targets/grafana_dashboard/tasks/dashboard-from-url.yml index 5146fc9a..28f887f8 100644 --- a/tests/integration/targets/grafana_dashboard/tasks/dashboard-from-url.yml +++ b/tests/integration/targets/grafana_dashboard/tasks/dashboard-from-url.yml @@ -1,7 +1,6 @@ --- - - name: Check import grafana dashboard from url - grafana_dashboard: + community.grafana.grafana_dashboard: grafana_url: "{{ grafana_url }}" grafana_user: "{{ grafana_username }}" grafana_password: "{{ grafana_password }}" @@ -11,16 +10,16 @@ overwrite: true register: result -- debug: +- ansible.builtin.debug: var: result -- assert: +- ansible.builtin.assert: that: - - "result.changed == true" - - "result.msg == 'Dashboard Zabbix Host Status created'" + - result.changed == true + - result.msg == 'Dashboard Zabbix Host Status created' - name: Check import grafana dashboard from url idempotency - grafana_dashboard: + community.grafana.grafana_dashboard: grafana_url: "{{ grafana_url }}" grafana_user: "{{ grafana_username }}" grafana_password: "{{ grafana_password }}" @@ -30,10 +29,10 @@ overwrite: true register: result -- debug: +- ansible.builtin.debug: var: result -- assert: +- ansible.builtin.assert: that: - - "result.changed == false" - - "result.msg == 'Dashboard Zabbix Host Status unchanged.'" + - result.changed == false + - result.msg == 'Dashboard Zabbix Host Status unchanged.' diff --git a/tests/integration/targets/grafana_dashboard/tasks/delete-dashboard.yml b/tests/integration/targets/grafana_dashboard/tasks/delete-dashboard.yml index 2013324f..d4ef3c60 100644 --- a/tests/integration/targets/grafana_dashboard/tasks/delete-dashboard.yml +++ b/tests/integration/targets/grafana_dashboard/tasks/delete-dashboard.yml @@ -1,5 +1,6 @@ +--- - name: Check delete dashboard is working - grafana_dashboard: + community.grafana.grafana_dashboard: grafana_url: "{{ grafana_url }}" grafana_user: "{{ grafana_username }}" grafana_password: "{{ grafana_password }}" @@ -7,10 +8,10 @@ uid: "{{ result.uid }}" register: result -- debug: +- ansible.builtin.debug: var: result -- assert: +- ansible.builtin.assert: that: - - "result.changed == true" - - "result.msg == 'Dashboard {{ result.uid }} deleted'" + - result.changed == true + - result.msg == 'Dashboard {{ result.uid }} deleted' diff --git a/tests/integration/targets/grafana_dashboard/tasks/main.yml b/tests/integration/targets/grafana_dashboard/tasks/main.yml index 570fb4d8..d4f1b771 100644 --- a/tests/integration/targets/grafana_dashboard/tasks/main.yml +++ b/tests/integration/targets/grafana_dashboard/tasks/main.yml @@ -1,7 +1,8 @@ +--- - block: - - include_tasks: dashboard-from-url.yml - - include_tasks: delete-dashboard.yml - - include_tasks: dashboard-from-id.yml - - include_tasks: dashboard-from-file.yml - - include_tasks: dashboard-export.yml - - include_tasks: dashboard-folder-destination.yml + - ansible.builtin.include_tasks: dashboard-from-url.yml + - ansible.builtin.include_tasks: delete-dashboard.yml + - ansible.builtin.include_tasks: dashboard-from-id.yml + - ansible.builtin.include_tasks: dashboard-from-file.yml + - ansible.builtin.include_tasks: dashboard-export.yml + - ansible.builtin.include_tasks: dashboard-folder-destination.yml diff --git a/tests/integration/targets/grafana_datasource/defaults/main.yml b/tests/integration/targets/grafana_datasource/defaults/main.yml index 8b9c9348..4abf9bb4 100644 --- a/tests/integration/targets/grafana_datasource/defaults/main.yml +++ b/tests/integration/targets/grafana_datasource/defaults/main.yml @@ -1,7 +1,5 @@ --- -grafana_url: "http://grafana:3000/" -grafana_username: "admin" -grafana_password: "admin" - -... +grafana_url: http://grafana:3000/ +grafana_username: admin +grafana_password: admin diff --git a/tests/integration/targets/grafana_datasource/tasks/azure.yml b/tests/integration/targets/grafana_datasource/tasks/azure.yml index a9669189..0dbd9496 100644 --- a/tests/integration/targets/grafana_datasource/tasks/azure.yml +++ b/tests/integration/targets/grafana_datasource/tasks/azure.yml @@ -1,11 +1,12 @@ +--- - name: Create azure datasource register: result - grafana_datasource: + community.grafana.grafana_datasource: name: datasource-azure grafana_url: "{{ grafana_url }}" grafana_user: "{{ grafana_username }}" - grafana_password: "{{ grafana_password}}" - org_id: '1' + grafana_password: "{{ grafana_password }}" + org_id: "1" ds_type: grafana-azure-monitor-datasource ds_url: http://example.com azure_client: client1 @@ -13,38 +14,38 @@ azure_secret: secret1 azure_cloud: azuremonitor -- debug: +- ansible.builtin.debug: var: result -- assert: +- ansible.builtin.assert: that: - - result.changed - - "result.msg == 'Datasource datasource-azure created'" - - result.datasource.access == 'proxy' - - result.datasource.basicAuth == false - - result.datasource.database == '' - - result.datasource.isDefault == false - - result.datasource.jsonData.clientId == 'client1' - - result.datasource.jsonData.cloudName == 'azuremonitor' - - result.datasource.jsonData.tenantId == 'tenant1' - - result.datasource.jsonData.tlsAuth == false - - result.datasource.jsonData.tlsAuthWithCACert == false - - result.datasource.name == 'datasource-azure' - - result.datasource.orgId == 1 - - ('password' not in result.datasource) or (result.datasource.password == '') - - result.datasource.type == 'grafana-azure-monitor-datasource' - - result.datasource.url == 'http://example.com' - - result.datasource.user == '' - - result.datasource.withCredentials == false + - result.changed + - result.msg == 'Datasource datasource-azure created' + - result.datasource.access == 'proxy' + - result.datasource.basicAuth == false + - result.datasource.database == '' + - result.datasource.isDefault == false + - result.datasource.jsonData.clientId == 'client1' + - result.datasource.jsonData.cloudName == 'azuremonitor' + - result.datasource.jsonData.tenantId == 'tenant1' + - result.datasource.jsonData.tlsAuth == false + - result.datasource.jsonData.tlsAuthWithCACert == false + - result.datasource.name == 'datasource-azure' + - result.datasource.orgId == 1 + - ('password' not in result.datasource) or (result.datasource.password == '') + - result.datasource.type == 'grafana-azure-monitor-datasource' + - result.datasource.url == 'http://example.com' + - result.datasource.user == '' + - result.datasource.withCredentials == false - name: Check azure datasource creation idempotency register: result - grafana_datasource: + community.grafana.grafana_datasource: name: datasource-azure grafana_url: "{{ grafana_url }}" grafana_user: "{{ grafana_username }}" - grafana_password: "{{ grafana_password}}" - org_id: '1' + grafana_password: "{{ grafana_password }}" + org_id: "1" ds_type: grafana-azure-monitor-datasource ds_url: http://example.com azure_client: client1 @@ -52,37 +53,37 @@ azure_secret: secret1 azure_cloud: azuremonitor -- debug: +- ansible.builtin.debug: var: result -- assert: +- ansible.builtin.assert: that: - - not result.changed - - result.datasource.access == 'proxy' - - result.datasource.basicAuth == false - - result.datasource.database == '' - - result.datasource.isDefault == false - - result.datasource.jsonData.clientId == 'client1' - - result.datasource.jsonData.cloudName == 'azuremonitor' - - result.datasource.jsonData.tenantId == 'tenant1' - - result.datasource.jsonData.tlsAuth == false - - result.datasource.jsonData.tlsAuthWithCACert == false - - result.datasource.name == 'datasource-azure' - - result.datasource.orgId == 1 - - ('password' not in result.datasource) or (result.datasource.password == '') - - result.datasource.type == 'grafana-azure-monitor-datasource' - - result.datasource.url == 'http://example.com' - - result.datasource.user == '' - - result.datasource.withCredentials == false + - not result.changed + - result.datasource.access == 'proxy' + - result.datasource.basicAuth == false + - result.datasource.database == '' + - result.datasource.isDefault == false + - result.datasource.jsonData.clientId == 'client1' + - result.datasource.jsonData.cloudName == 'azuremonitor' + - result.datasource.jsonData.tenantId == 'tenant1' + - result.datasource.jsonData.tlsAuth == false + - result.datasource.jsonData.tlsAuthWithCACert == false + - result.datasource.name == 'datasource-azure' + - result.datasource.orgId == 1 + - ('password' not in result.datasource) or (result.datasource.password == '') + - result.datasource.type == 'grafana-azure-monitor-datasource' + - result.datasource.url == 'http://example.com' + - result.datasource.user == '' + - result.datasource.withCredentials == false - name: Delete azure datasource register: result - grafana_datasource: + community.grafana.grafana_datasource: name: datasource-azure grafana_url: "{{ grafana_url }}" grafana_user: "{{ grafana_username }}" - grafana_password: "{{ grafana_password}}" - org_id: '1' + grafana_password: "{{ grafana_password }}" + org_id: "1" ds_type: grafana-azure-monitor-datasource ds_url: http://example.com azure_client: client1 @@ -91,22 +92,22 @@ azure_cloud: azuremonitor state: absent -- debug: +- ansible.builtin.debug: var: result -- assert: +- ansible.builtin.assert: that: - - result.changed - - "result.msg == 'Datasource datasource-azure deleted.'" + - result.changed + - result.msg == 'Datasource datasource-azure deleted.' - name: Delete azure datasource (idempotency) register: result - grafana_datasource: + community.grafana.grafana_datasource: name: datasource-azure grafana_url: "{{ grafana_url }}" grafana_user: "{{ grafana_username }}" - grafana_password: "{{ grafana_password}}" - org_id: '1' + grafana_password: "{{ grafana_password }}" + org_id: "1" ds_type: grafana-azure-monitor-datasource ds_url: http://example.com azure_client: client1 @@ -115,9 +116,9 @@ azure_cloud: azuremonitor state: absent -- debug: +- ansible.builtin.debug: var: result -- assert: +- ansible.builtin.assert: that: - - not result.changed + - not result.changed diff --git a/tests/integration/targets/grafana_datasource/tasks/cloudwatch.yml b/tests/integration/targets/grafana_datasource/tasks/cloudwatch.yml index 50268ea8..79408b68 100644 --- a/tests/integration/targets/grafana_datasource/tasks/cloudwatch.yml +++ b/tests/integration/targets/grafana_datasource/tasks/cloudwatch.yml @@ -1,11 +1,12 @@ +--- - name: Create cloudwatch datasource register: result - grafana_datasource: + community.grafana.grafana_datasource: name: datasource-cloudwatch grafana_url: "{{ grafana_url }}" grafana_user: "{{ grafana_username }}" - grafana_password: "{{ grafana_password}}" - org_id: '1' + grafana_password: "{{ grafana_password }}" + org_id: "1" ds_type: cloudwatch ds_url: http://monitoring.us-west-1.amazonaws.com aws_auth_type: keys @@ -14,38 +15,38 @@ aws_secret_key: mel10n aws_custom_metrics_namespaces: n1,n2 -- debug: +- ansible.builtin.debug: var: result -- assert: +- ansible.builtin.assert: that: - - result.changed - - "result.msg == 'Datasource datasource-cloudwatch created'" - - result.datasource.access == 'proxy' - - result.datasource.basicAuth == false - - result.datasource.database == '' - - result.datasource.isDefault == false - - result.datasource.jsonData.authType == 'keys' - - result.datasource.jsonData.customMetricsNamespaces == 'n1,n2' - - result.datasource.jsonData.defaultRegion == 'us-west-1' - - result.datasource.jsonData.tlsAuth == false - - result.datasource.jsonData.tlsAuthWithCACert == false - - result.datasource.name == 'datasource-cloudwatch' - - result.datasource.orgId == 1 - - ('password' not in result.datasource) or (result.datasource.password == '') - - result.datasource.type == 'cloudwatch' - - result.datasource.url == 'http://monitoring.us-west-1.amazonaws.com' - - result.datasource.user == '' - - result.datasource.withCredentials == false + - result.changed + - result.msg == 'Datasource datasource-cloudwatch created' + - result.datasource.access == 'proxy' + - result.datasource.basicAuth == false + - result.datasource.database == '' + - result.datasource.isDefault == false + - result.datasource.jsonData.authType == 'keys' + - result.datasource.jsonData.customMetricsNamespaces == 'n1,n2' + - result.datasource.jsonData.defaultRegion == 'us-west-1' + - result.datasource.jsonData.tlsAuth == false + - result.datasource.jsonData.tlsAuthWithCACert == false + - result.datasource.name == 'datasource-cloudwatch' + - result.datasource.orgId == 1 + - ('password' not in result.datasource) or (result.datasource.password == '') + - result.datasource.type == 'cloudwatch' + - result.datasource.url == 'http://monitoring.us-west-1.amazonaws.com' + - result.datasource.user == '' + - result.datasource.withCredentials == false - name: Check cloudwatch datasource creation idempotency register: result - grafana_datasource: + community.grafana.grafana_datasource: name: datasource-cloudwatch grafana_url: "{{ grafana_url }}" grafana_user: "{{ grafana_username }}" grafana_password: "{{ grafana_password }}" - org_id: '1' + org_id: "1" ds_type: cloudwatch ds_url: http://monitoring.us-west-1.amazonaws.com aws_auth_type: keys @@ -54,58 +55,58 @@ aws_secret_key: mel10n aws_custom_metrics_namespaces: n1,n2 -- debug: +- ansible.builtin.debug: var: result -- assert: +- ansible.builtin.assert: that: - - not result.changed - - result.datasource.access == 'proxy' - - result.datasource.basicAuth == false - - result.datasource.database == '' - - result.datasource.isDefault == false - - result.datasource.jsonData.authType == 'keys' - - result.datasource.jsonData.customMetricsNamespaces == 'n1,n2' - - result.datasource.jsonData.defaultRegion == 'us-west-1' - - result.datasource.jsonData.tlsAuth == false - - result.datasource.jsonData.tlsAuthWithCACert == false - - result.datasource.name == 'datasource-cloudwatch' - - result.datasource.orgId == 1 - - ('password' not in result.datasource) or (result.datasource.password == '') - - result.datasource.type == 'cloudwatch' - - result.datasource.url == 'http://monitoring.us-west-1.amazonaws.com' - - result.datasource.user == '' - - result.datasource.withCredentials == false + - not result.changed + - result.datasource.access == 'proxy' + - result.datasource.basicAuth == false + - result.datasource.database == '' + - result.datasource.isDefault == false + - result.datasource.jsonData.authType == 'keys' + - result.datasource.jsonData.customMetricsNamespaces == 'n1,n2' + - result.datasource.jsonData.defaultRegion == 'us-west-1' + - result.datasource.jsonData.tlsAuth == false + - result.datasource.jsonData.tlsAuthWithCACert == false + - result.datasource.name == 'datasource-cloudwatch' + - result.datasource.orgId == 1 + - ('password' not in result.datasource) or (result.datasource.password == '') + - result.datasource.type == 'cloudwatch' + - result.datasource.url == 'http://monitoring.us-west-1.amazonaws.com' + - result.datasource.user == '' + - result.datasource.withCredentials == false - name: Delete cloudwatch datasource register: result - grafana_datasource: + community.grafana.grafana_datasource: name: datasource-cloudwatch grafana_url: "{{ grafana_url }}" grafana_user: "{{ grafana_username }}" - grafana_password: "{{ grafana_password}}" + grafana_password: "{{ grafana_password }}" state: absent -- debug: +- ansible.builtin.debug: var: result -- assert: +- ansible.builtin.assert: that: - - result.changed - - "result.msg == 'Datasource datasource-cloudwatch deleted.'" + - result.changed + - result.msg == 'Datasource datasource-cloudwatch deleted.' - name: Delete cloudwatch datasource (idempotency) register: result - grafana_datasource: + community.grafana.grafana_datasource: name: datasource-cloudwatch grafana_url: "{{ grafana_url }}" grafana_user: "{{ grafana_username }}" - grafana_password: "{{ grafana_password}}" + grafana_password: "{{ grafana_password }}" state: absent -- debug: +- ansible.builtin.debug: var: result -- assert: +- ansible.builtin.assert: that: - - not result.changed + - not result.changed diff --git a/tests/integration/targets/grafana_datasource/tasks/elastic.yml b/tests/integration/targets/grafana_datasource/tasks/elastic.yml index 73b25842..ff05b93f 100644 --- a/tests/integration/targets/grafana_datasource/tasks/elastic.yml +++ b/tests/integration/targets/grafana_datasource/tasks/elastic.yml @@ -1,313 +1,313 @@ --- - name: Create elasticsearch datasource with legacy elasticsearch format register: result - grafana_datasource: - name: "datasource/elasticLegacy" - uid: "myuid" + community.grafana.grafana_datasource: + name: datasource/elasticLegacy + uid: myuid grafana_url: "{{ grafana_url }}" grafana_user: "{{ grafana_username }}" grafana_password: "{{ grafana_password }}" - org_id: '1' + org_id: "1" ds_type: elasticsearch ds_url: https://elastic.company.com:9200 - database: '[logstash_]YYYY.MM.DD' + database: "[logstash_]YYYY.MM.DD" basic_auth_user: grafana - basic_auth_password: '******' - time_field: '@timestamp' + basic_auth_password: "******" + time_field: "@timestamp" time_interval: 1m interval: Daily es_version: 56 max_concurrent_shard_requests: 42 tls_ca_cert: /etc/ssl/certs/ca.pem -- debug: +- ansible.builtin.debug: var: result -- assert: +- ansible.builtin.assert: that: - - result.changed - - result.datasource.basicAuth - - result.datasource.basicAuthUser == 'grafana' - - result.datasource.access == 'proxy' - - result.datasource.database == '[logstash_]YYYY.MM.DD' - - not result.datasource.isDefault - - result.datasource.jsonData.esVersion == 56 - - result.datasource.jsonData.interval == 'Daily' - - result.datasource.jsonData.maxConcurrentShardRequests == 42 - - result.datasource.jsonData.timeField == '@timestamp' - - not result.datasource.jsonData.tlsAuth - - result.datasource.jsonData.tlsAuthWithCACert - - result.datasource.name == 'datasource/elasticLegacy' - - result.datasource.orgId == 1 - - ('password' not in result.datasource) or (result.datasource.password == '') - - result.datasource.type == 'elasticsearch' - - result.datasource.url == 'https://elastic.company.com:9200' - - result.datasource.user == '' - - not result.datasource.withCredentials - - "result.msg == 'Datasource datasource/elasticLegacy created'" + - result.changed + - result.datasource.basicAuth + - result.datasource.basicAuthUser == 'grafana' + - result.datasource.access == 'proxy' + - result.datasource.database == '[logstash_]YYYY.MM.DD' + - not result.datasource.isDefault + - result.datasource.jsonData.esVersion == 56 + - result.datasource.jsonData.interval == 'Daily' + - result.datasource.jsonData.maxConcurrentShardRequests == 42 + - result.datasource.jsonData.timeField == '@timestamp' + - not result.datasource.jsonData.tlsAuth + - result.datasource.jsonData.tlsAuthWithCACert + - result.datasource.name == 'datasource/elasticLegacy' + - result.datasource.orgId == 1 + - ('password' not in result.datasource) or (result.datasource.password == '') + - result.datasource.type == 'elasticsearch' + - result.datasource.url == 'https://elastic.company.com:9200' + - result.datasource.user == '' + - not result.datasource.withCredentials + - result.msg == 'Datasource datasource/elasticLegacy created' - name: Create elasticsearch datasource with new elsaticsearch version format register: result - grafana_datasource: - name: "datasource/elastic" + community.grafana.grafana_datasource: + name: datasource/elastic grafana_url: "{{ grafana_url }}" grafana_user: "{{ grafana_username }}" grafana_password: "{{ grafana_password }}" - org_id: '1' + org_id: "1" ds_type: elasticsearch ds_url: https://elastic.company.com:9200 - database: '[logstash_]YYYY.MM.DD' + database: "[logstash_]YYYY.MM.DD" basic_auth_user: grafana - basic_auth_password: '******' - time_field: '@timestamp' + basic_auth_password: "******" + time_field: "@timestamp" time_interval: 1m interval: Daily - es_version: "7.10+" + es_version: 7.10+ max_concurrent_shard_requests: 42 tls_ca_cert: /etc/ssl/certs/ca.pem -- debug: +- ansible.builtin.debug: var: result -- assert: +- ansible.builtin.assert: that: - - result.changed - - result.datasource.basicAuth - - result.datasource.basicAuthUser == 'grafana' - - result.datasource.access == 'proxy' - - result.datasource.database == '[logstash_]YYYY.MM.DD' - - not result.datasource.isDefault - - result.datasource.jsonData.esVersion == "7.10.0" - - result.datasource.jsonData.interval == 'Daily' - - result.datasource.jsonData.maxConcurrentShardRequests == 42 - - result.datasource.jsonData.timeField == '@timestamp' - - not result.datasource.jsonData.tlsAuth - - result.datasource.jsonData.tlsAuthWithCACert - - result.datasource.name == 'datasource/elastic' - - result.datasource.orgId == 1 - - ('password' not in result.datasource) or (result.datasource.password == '') - - result.datasource.type == 'elasticsearch' - - result.datasource.url == 'https://elastic.company.com:9200' - - result.datasource.user == '' - - not result.datasource.withCredentials - - "result.msg == 'Datasource datasource/elastic created'" + - result.changed + - result.datasource.basicAuth + - result.datasource.basicAuthUser == 'grafana' + - result.datasource.access == 'proxy' + - result.datasource.database == '[logstash_]YYYY.MM.DD' + - not result.datasource.isDefault + - result.datasource.jsonData.esVersion == "7.10.0" + - result.datasource.jsonData.interval == 'Daily' + - result.datasource.jsonData.maxConcurrentShardRequests == 42 + - result.datasource.jsonData.timeField == '@timestamp' + - not result.datasource.jsonData.tlsAuth + - result.datasource.jsonData.tlsAuthWithCACert + - result.datasource.name == 'datasource/elastic' + - result.datasource.orgId == 1 + - ('password' not in result.datasource) or (result.datasource.password == '') + - result.datasource.type == 'elasticsearch' + - result.datasource.url == 'https://elastic.company.com:9200' + - result.datasource.user == '' + - not result.datasource.withCredentials + - result.msg == 'Datasource datasource/elastic created' - name: Check elasticsearch datasource creation idempotency register: result - grafana_datasource: - name: "datasource/elastic" + community.grafana.grafana_datasource: + name: datasource/elastic grafana_url: "{{ grafana_url }}" grafana_user: "{{ grafana_username }}" grafana_password: "{{ grafana_password }}" - org_id: '1' + org_id: "1" ds_type: elasticsearch ds_url: https://elastic.company.com:9200 - database: '[logstash_]YYYY.MM.DD' + database: "[logstash_]YYYY.MM.DD" basic_auth_user: grafana - basic_auth_password: '******' - time_field: '@timestamp' + basic_auth_password: "******" + time_field: "@timestamp" time_interval: 1m interval: Daily - es_version: "7.10+" + es_version: 7.10+ max_concurrent_shard_requests: 42 tls_ca_cert: /etc/ssl/certs/ca.pem -- debug: +- ansible.builtin.debug: var: result -- assert: +- ansible.builtin.assert: that: - - not result.changed - - result.datasource.basicAuth - - result.datasource.basicAuthUser == 'grafana' - - result.datasource.access == 'proxy' - - result.datasource.database == '[logstash_]YYYY.MM.DD' - - not result.datasource.isDefault - - result.datasource.jsonData.esVersion == '7.10.0' - - result.datasource.jsonData.interval == 'Daily' - - result.datasource.jsonData.maxConcurrentShardRequests == 42 - - result.datasource.jsonData.timeField == '@timestamp' - - not result.datasource.jsonData.tlsAuth - - result.datasource.jsonData.tlsAuthWithCACert - - result.datasource.name == 'datasource/elastic' - - result.datasource.orgId == 1 - - ('password' not in result.datasource) or (result.datasource.password == '') - - result.datasource.type == 'elasticsearch' - - result.datasource.url == 'https://elastic.company.com:9200' - - result.datasource.user == '' - - not result.datasource.withCredentials + - not result.changed + - result.datasource.basicAuth + - result.datasource.basicAuthUser == 'grafana' + - result.datasource.access == 'proxy' + - result.datasource.database == '[logstash_]YYYY.MM.DD' + - not result.datasource.isDefault + - result.datasource.jsonData.esVersion == '7.10.0' + - result.datasource.jsonData.interval == 'Daily' + - result.datasource.jsonData.maxConcurrentShardRequests == 42 + - result.datasource.jsonData.timeField == '@timestamp' + - not result.datasource.jsonData.tlsAuth + - result.datasource.jsonData.tlsAuthWithCACert + - result.datasource.name == 'datasource/elastic' + - result.datasource.orgId == 1 + - ('password' not in result.datasource) or (result.datasource.password == '') + - result.datasource.type == 'elasticsearch' + - result.datasource.url == 'https://elastic.company.com:9200' + - result.datasource.user == '' + - not result.datasource.withCredentials -- name: update elasticsearch datasource creation +- name: Update elasticsearch datasource creation register: result - grafana_datasource: - name: "datasource/elastic" + community.grafana.grafana_datasource: + name: datasource/elastic grafana_url: "{{ grafana_url }}" grafana_user: "{{ grafana_username }}" grafana_password: "{{ grafana_password }}" - org_id: '1' + org_id: "1" ds_type: elasticsearch ds_url: https://elastic.example.com:9200 - database: '[logstash_]YYYY.MM.DD' + database: "[logstash_]YYYY.MM.DD" basic_auth_user: grafana - basic_auth_password: '******' - time_field: '@timestamp' + basic_auth_password: "******" + time_field: "@timestamp" time_interval: 1m interval: Daily - es_version: "7.10+" + es_version: 7.10+ max_concurrent_shard_requests: 42 tls_ca_cert: /etc/ssl/certs/ca.pem -- debug: +- ansible.builtin.debug: var: result -- assert: +- ansible.builtin.assert: that: - - result.changed - - result.datasource.basicAuth - - result.datasource.basicAuthUser == 'grafana' - - result.datasource.access == 'proxy' - - result.datasource.database == '[logstash_]YYYY.MM.DD' - - not result.datasource.isDefault - - result.datasource.jsonData.esVersion == '7.10.0' - - result.datasource.jsonData.interval == 'Daily' - - result.datasource.jsonData.maxConcurrentShardRequests == 42 - - result.datasource.jsonData.timeField == '@timestamp' - - not result.datasource.jsonData.tlsAuth - - result.datasource.jsonData.tlsAuthWithCACert - - result.datasource.name == 'datasource/elastic' - - result.datasource.orgId == 1 - - ('password' not in result.datasource) or (result.datasource.password == '') - - result.datasource.type == 'elasticsearch' - - result.datasource.url == 'https://elastic.example.com:9200' - - result.datasource.user == '' - - not result.datasource.withCredentials + - result.changed + - result.datasource.basicAuth + - result.datasource.basicAuthUser == 'grafana' + - result.datasource.access == 'proxy' + - result.datasource.database == '[logstash_]YYYY.MM.DD' + - not result.datasource.isDefault + - result.datasource.jsonData.esVersion == '7.10.0' + - result.datasource.jsonData.interval == 'Daily' + - result.datasource.jsonData.maxConcurrentShardRequests == 42 + - result.datasource.jsonData.timeField == '@timestamp' + - not result.datasource.jsonData.tlsAuth + - result.datasource.jsonData.tlsAuthWithCACert + - result.datasource.name == 'datasource/elastic' + - result.datasource.orgId == 1 + - ('password' not in result.datasource) or (result.datasource.password == '') + - result.datasource.type == 'elasticsearch' + - result.datasource.url == 'https://elastic.example.com:9200' + - result.datasource.user == '' + - not result.datasource.withCredentials -- name: update elasticsearch datasource (ignoring secureJsonData) +- name: Update elasticsearch datasource (ignoring secureJsonData) register: result - grafana_datasource: - name: "datasource/elastic" + community.grafana.grafana_datasource: + name: datasource/elastic grafana_url: "{{ grafana_url }}" grafana_user: "{{ grafana_username }}" grafana_password: "{{ grafana_password }}" - org_id: '1' + org_id: "1" ds_type: elasticsearch ds_url: https://elastic.example.com:9200 - database: '[logstash_]YYYY.MM.DD' + database: "[logstash_]YYYY.MM.DD" basic_auth_user: grafana - basic_auth_password: '******' - time_field: '@timestamp' + basic_auth_password: "******" + time_field: "@timestamp" time_interval: 1m interval: Daily - es_version: "7.10+" + es_version: 7.10+ max_concurrent_shard_requests: 42 tls_ca_cert: /etc/ssl/certs/ca.pem enforce_secure_data: false additional_json_data: - nonSecureTest: "nonsecure" + nonSecureTest: nonsecure additional_secure_json_data: - secureTest: "secure" + secureTest: secure -- debug: +- ansible.builtin.debug: var: result -- assert: +- ansible.builtin.assert: that: - - result.changed - - result.datasource.basicAuth - - result.datasource.basicAuthUser == 'grafana' - - result.datasource.access == 'proxy' - - result.datasource.database == '[logstash_]YYYY.MM.DD' - - not result.datasource.isDefault - - result.datasource.jsonData.esVersion == '7.10.0' - - result.datasource.jsonData.interval == 'Daily' - - result.datasource.jsonData.maxConcurrentShardRequests == 42 - - result.datasource.jsonData.timeField == '@timestamp' - - not result.datasource.jsonData.tlsAuth - - result.datasource.jsonData.tlsAuthWithCACert - - result.datasource.name == 'datasource/elastic' - - result.datasource.orgId == 1 - - ('password' not in result.datasource) or (result.datasource.password == '') - - result.datasource.type == 'elasticsearch' - - result.datasource.url == 'https://elastic.example.com:9200' - - result.datasource.user == '' - - not result.datasource.withCredentials - - result.datasource.jsonData.nonSecureTest == 'nonsecure' + - result.changed + - result.datasource.basicAuth + - result.datasource.basicAuthUser == 'grafana' + - result.datasource.access == 'proxy' + - result.datasource.database == '[logstash_]YYYY.MM.DD' + - not result.datasource.isDefault + - result.datasource.jsonData.esVersion == '7.10.0' + - result.datasource.jsonData.interval == 'Daily' + - result.datasource.jsonData.maxConcurrentShardRequests == 42 + - result.datasource.jsonData.timeField == '@timestamp' + - not result.datasource.jsonData.tlsAuth + - result.datasource.jsonData.tlsAuthWithCACert + - result.datasource.name == 'datasource/elastic' + - result.datasource.orgId == 1 + - ('password' not in result.datasource) or (result.datasource.password == '') + - result.datasource.type == 'elasticsearch' + - result.datasource.url == 'https://elastic.example.com:9200' + - result.datasource.user == '' + - not result.datasource.withCredentials + - result.datasource.jsonData.nonSecureTest == 'nonsecure' -- name: update elasticsearch datasource (including secureJsonData) +- name: Update elasticsearch datasource (including secureJsonData) register: result - grafana_datasource: - name: "datasource/elastic" + community.grafana.grafana_datasource: + name: datasource/elastic grafana_url: "{{ grafana_url }}" grafana_user: "{{ grafana_username }}" grafana_password: "{{ grafana_password }}" - org_id: '1' + org_id: "1" ds_type: elasticsearch ds_url: https://elastic.example.com:9200 - database: '[logstash_]YYYY.MM.DD' + database: "[logstash_]YYYY.MM.DD" basic_auth_user: grafana - basic_auth_password: '******' - time_field: '@timestamp' + basic_auth_password: "******" + time_field: "@timestamp" time_interval: 1m interval: Daily - es_version: "7.10+" + es_version: 7.10+ max_concurrent_shard_requests: 42 tls_ca_cert: /etc/ssl/certs/ca.pem enforce_secure_data: true additional_json_data: - nonSecureTest: "nonsecure" + nonSecureTest: nonsecure additional_secure_json_data: - secureTest: "secure" + secureTest: secure -- debug: +- ansible.builtin.debug: var: result -- assert: +- ansible.builtin.assert: that: - - result.changed - - result.datasource.basicAuth - - result.datasource.basicAuthUser == 'grafana' - - result.datasource.access == 'proxy' - - result.datasource.database == '[logstash_]YYYY.MM.DD' - - not result.datasource.isDefault - - result.datasource.jsonData.esVersion == '7.10.0' - - result.datasource.jsonData.interval == 'Daily' - - result.datasource.jsonData.maxConcurrentShardRequests == 42 - - result.datasource.jsonData.timeField == '@timestamp' - - not result.datasource.jsonData.tlsAuth - - result.datasource.jsonData.tlsAuthWithCACert - - result.datasource.name == 'datasource/elastic' - - result.datasource.orgId == 1 - - ('password' not in result.datasource) or (result.datasource.password == '') - - result.datasource.type == 'elasticsearch' - - result.datasource.url == 'https://elastic.example.com:9200' - - result.datasource.user == '' - - not result.datasource.withCredentials - - result.datasource.jsonData.nonSecureTest == 'nonsecure' - - result.datasource.secureJsonFields.secureTest == true - - result.diff.after.secureJsonData is defined + - result.changed + - result.datasource.basicAuth + - result.datasource.basicAuthUser == 'grafana' + - result.datasource.access == 'proxy' + - result.datasource.database == '[logstash_]YYYY.MM.DD' + - not result.datasource.isDefault + - result.datasource.jsonData.esVersion == '7.10.0' + - result.datasource.jsonData.interval == 'Daily' + - result.datasource.jsonData.maxConcurrentShardRequests == 42 + - result.datasource.jsonData.timeField == '@timestamp' + - not result.datasource.jsonData.tlsAuth + - result.datasource.jsonData.tlsAuthWithCACert + - result.datasource.name == 'datasource/elastic' + - result.datasource.orgId == 1 + - ('password' not in result.datasource) or (result.datasource.password == '') + - result.datasource.type == 'elasticsearch' + - result.datasource.url == 'https://elastic.example.com:9200' + - result.datasource.user == '' + - not result.datasource.withCredentials + - result.datasource.jsonData.nonSecureTest == 'nonsecure' + - result.datasource.secureJsonFields.secureTest == true + - result.diff.after.secureJsonData is defined - name: Delete elasticsearch datasource register: result - grafana_datasource: - name: "datasource/elastic" + community.grafana.grafana_datasource: + name: datasource/elastic grafana_url: "{{ grafana_url }}" grafana_user: "{{ grafana_username }}" grafana_password: "{{ grafana_password }}" state: absent -- assert: +- ansible.builtin.assert: that: - - result.changed + - result.changed - name: Delete elasticsearch datasource (idempotency) register: result - grafana_datasource: - name: "datasource/elastic" + community.grafana.grafana_datasource: + name: datasource/elastic grafana_url: "{{ grafana_url }}" grafana_user: "{{ grafana_username }}" grafana_password: "{{ grafana_password }}" state: absent -- assert: +- ansible.builtin.assert: that: - - not result.changed + - not result.changed diff --git a/tests/integration/targets/grafana_datasource/tasks/errors.yml b/tests/integration/targets/grafana_datasource/tasks/errors.yml index 731a19d8..779b4724 100644 --- a/tests/integration/targets/grafana_datasource/tasks/errors.yml +++ b/tests/integration/targets/grafana_datasource/tasks/errors.yml @@ -1,18 +1,18 @@ --- - name: Create datasource without `ds_type` and `ds_url` (expect failure) register: result - grafana_datasource: + community.grafana.grafana_datasource: name: datasource-postgres grafana_url: "{{ grafana_url }}" grafana_user: "{{ grafana_username }}" grafana_password: "{{ grafana_password }}" ignore_errors: true -- debug: +- ansible.builtin.debug: var: result -- assert: +- ansible.builtin.assert: that: - - not result.changed - - result.failed - - "result.msg == 'state is present but all of the following are missing: ds_type, ds_url'" + - not result.changed + - result.failed + - "result.msg == 'state is present but all of the following are missing: ds_type, ds_url'" diff --git a/tests/integration/targets/grafana_datasource/tasks/influx.yml b/tests/integration/targets/grafana_datasource/tasks/influx.yml index da61833f..7952bec6 100644 --- a/tests/integration/targets/grafana_datasource/tasks/influx.yml +++ b/tests/integration/targets/grafana_datasource/tasks/influx.yml @@ -1,88 +1,89 @@ +--- - name: Create influxdb datasource register: result - grafana_datasource: + community.grafana.grafana_datasource: name: datasource-influxdb grafana_url: "{{ grafana_url }}" grafana_user: "{{ grafana_username }}" grafana_password: "{{ grafana_password }}" - org_id: '1' + org_id: "1" ds_type: influxdb ds_url: https://influx.company.com:8086 database: telegraf - time_interval: '>10s' + time_interval: ">10s" tls_ca_cert: /etc/ssl/certs/ca.pem -- debug: +- ansible.builtin.debug: var: result -- assert: +- ansible.builtin.assert: that: - - result.changed - - "result.msg == 'Datasource datasource-influxdb created'" + - result.changed + - result.msg == 'Datasource datasource-influxdb created' - name: Check influxdb datasource creation idempotency register: result - grafana_datasource: + community.grafana.grafana_datasource: name: datasource-influxdb grafana_url: "{{ grafana_url }}" grafana_user: "{{ grafana_username }}" grafana_password: "{{ grafana_password }}" - org_id: '1' + org_id: "1" ds_type: influxdb ds_url: https://influx.company.com:8086 database: telegraf - time_interval: '>10s' + time_interval: ">10s" tls_ca_cert: /etc/ssl/certs/ca.pem -- debug: +- ansible.builtin.debug: var: result -- assert: +- ansible.builtin.assert: that: - - not result.changed - - result.datasource.basicAuth == false - - result.datasource.access == 'proxy' - - result.datasource.database == 'telegraf' - - result.datasource.isDefault == false - - result.datasource.jsonData.timeInterval == '>10s' - - result.datasource.jsonData.tlsAuth == false - - result.datasource.jsonData.tlsAuthWithCACert - - result.datasource.name == 'datasource-influxdb' - - result.datasource.orgId == 1 - - ('password' not in result.datasource) or (result.datasource.password == '') - - result.datasource.type == 'influxdb' - - result.datasource.url == 'https://influx.company.com:8086' - - result.datasource.user == '' - - result.datasource.withCredentials == false + - not result.changed + - result.datasource.basicAuth == false + - result.datasource.access == 'proxy' + - result.datasource.database == 'telegraf' + - result.datasource.isDefault == false + - result.datasource.jsonData.timeInterval == '>10s' + - result.datasource.jsonData.tlsAuth == false + - result.datasource.jsonData.tlsAuthWithCACert + - result.datasource.name == 'datasource-influxdb' + - result.datasource.orgId == 1 + - ('password' not in result.datasource) or (result.datasource.password == '') + - result.datasource.type == 'influxdb' + - result.datasource.url == 'https://influx.company.com:8086' + - result.datasource.user == '' + - result.datasource.withCredentials == false - name: Delete influxdb datasource register: result - grafana_datasource: + community.grafana.grafana_datasource: name: datasource-influxdb grafana_url: "{{ grafana_url }}" grafana_user: "{{ grafana_username }}" grafana_password: "{{ grafana_password }}" state: absent -- debug: +- ansible.builtin.debug: var: result -- assert: +- ansible.builtin.assert: that: - - result.changed + - result.changed - name: Delete influxdb datasource (idempotency) register: result - grafana_datasource: + community.grafana.grafana_datasource: name: datasource-influxdb grafana_url: "{{ grafana_url }}" grafana_user: "{{ grafana_username }}" grafana_password: "{{ grafana_password }}" state: absent -- debug: +- ansible.builtin.debug: var: result -- assert: +- ansible.builtin.assert: that: - - not result.changed + - not result.changed diff --git a/tests/integration/targets/grafana_datasource/tasks/issues.yml b/tests/integration/targets/grafana_datasource/tasks/issues.yml index f80677d8..3b4df5a7 100644 --- a/tests/integration/targets/grafana_datasource/tasks/issues.yml +++ b/tests/integration/targets/grafana_datasource/tasks/issues.yml @@ -1,46 +1,43 @@ --- - -- name: test datasource name with slash +- name: Test datasource name with slash register: result - grafana_datasource: - name: "datasource/elastic" + community.grafana.grafana_datasource: + name: datasource/elastic grafana_url: "{{ grafana_url }}" grafana_user: "{{ grafana_username }}" grafana_password: "{{ grafana_password }}" - org_id: '1' + org_id: "1" ds_type: elasticsearch ds_url: https://elastic.company.com:9200 - database: '[logstash_]YYYY.MM.DD' + database: "[logstash_]YYYY.MM.DD" basic_auth_user: grafana - basic_auth_password: '******' - time_field: '@timestamp' + basic_auth_password: "******" + time_field: "@timestamp" time_interval: 1m interval: Daily es_version: 56 max_concurrent_shard_requests: 42 tls_ca_cert: /etc/ssl/certs/ca.pem -- assert: +- ansible.builtin.assert: that: - - result.changed - - result.datasource.basicAuth - - result.datasource.basicAuthUser == 'grafana' - - result.datasource.access == 'proxy' - - result.datasource.database == '[logstash_]YYYY.MM.DD' - - not result.datasource.isDefault - - result.datasource.jsonData.esVersion == 56 - - result.datasource.jsonData.interval == 'Daily' - - result.datasource.jsonData.maxConcurrentShardRequests == 42 - - result.datasource.jsonData.timeField == '@timestamp' - - not result.datasource.jsonData.tlsAuth - - not result.datasource.jsonData.tlsAuthWithCACert - - result.datasource.name == 'datasource/elastic' - - result.datasource.orgId == 1 - - ('password' not in result.datasource) or (result.datasource.password == '') - - result.datasource.type == 'elasticsearch' - - result.datasource.url == 'https://elastic.company.com:9200' - - result.datasource.user == '' - - not result.datasource.withCredentials - - "result.msg == 'Datasource datasource/elastic created'" - -... + - result.changed + - result.datasource.basicAuth + - result.datasource.basicAuthUser == 'grafana' + - result.datasource.access == 'proxy' + - result.datasource.database == '[logstash_]YYYY.MM.DD' + - not result.datasource.isDefault + - result.datasource.jsonData.esVersion == 56 + - result.datasource.jsonData.interval == 'Daily' + - result.datasource.jsonData.maxConcurrentShardRequests == 42 + - result.datasource.jsonData.timeField == '@timestamp' + - not result.datasource.jsonData.tlsAuth + - not result.datasource.jsonData.tlsAuthWithCACert + - result.datasource.name == 'datasource/elastic' + - result.datasource.orgId == 1 + - ('password' not in result.datasource) or (result.datasource.password == '') + - result.datasource.type == 'elasticsearch' + - result.datasource.url == 'https://elastic.company.com:9200' + - result.datasource.user == '' + - not result.datasource.withCredentials + - result.msg == 'Datasource datasource/elastic created' diff --git a/tests/integration/targets/grafana_datasource/tasks/loki.yml b/tests/integration/targets/grafana_datasource/tasks/loki.yml index 68eca980..a501b99d 100644 --- a/tests/integration/targets/grafana_datasource/tasks/loki.yml +++ b/tests/integration/targets/grafana_datasource/tasks/loki.yml @@ -1,82 +1,83 @@ +--- - name: Create loki datasource register: result - grafana_datasource: + community.grafana.grafana_datasource: name: datasource-loki grafana_url: "{{ grafana_url }}" grafana_user: "{{ grafana_username }}" - grafana_password: "{{ grafana_password}}" - org_id: '1' + grafana_password: "{{ grafana_password }}" + org_id: "1" ds_type: loki ds_url: https://loki.company.com:3100 -- debug: +- ansible.builtin.debug: var: result -- assert: +- ansible.builtin.assert: that: - - result.changed - - "result.msg == 'Datasource datasource-loki created'" + - result.changed + - result.msg == 'Datasource datasource-loki created' - name: Check loki datasource creation idempotency register: result - grafana_datasource: + community.grafana.grafana_datasource: name: datasource-loki grafana_url: "{{ grafana_url }}" grafana_user: "{{ grafana_username }}" grafana_password: "{{ grafana_password }}" - org_id: '1' + org_id: "1" ds_type: loki ds_url: https://loki.company.com:3100 -- debug: +- ansible.builtin.debug: var: result -- assert: +- ansible.builtin.assert: that: - - not result.changed - - result.datasource.basicAuth == false - - result.datasource.access == 'proxy' - - result.datasource.database == '' - - result.datasource.isDefault == false - - result.datasource.jsonData.tlsAuth == false - - result.datasource.jsonData.tlsAuthWithCACert == false - - result.datasource.name == 'datasource-loki' - - result.datasource.orgId == 1 - - ('password' not in result.datasource) or (result.datasource.password == '') - - result.datasource.type == 'loki' - - result.datasource.url == 'https://loki.company.com:3100' - - result.datasource.user == '' - - result.datasource.withCredentials == false + - not result.changed + - result.datasource.basicAuth == false + - result.datasource.access == 'proxy' + - result.datasource.database == '' + - result.datasource.isDefault == false + - result.datasource.jsonData.tlsAuth == false + - result.datasource.jsonData.tlsAuthWithCACert == false + - result.datasource.name == 'datasource-loki' + - result.datasource.orgId == 1 + - ('password' not in result.datasource) or (result.datasource.password == '') + - result.datasource.type == 'loki' + - result.datasource.url == 'https://loki.company.com:3100' + - result.datasource.user == '' + - result.datasource.withCredentials == false - name: Delete loki datasource register: result - grafana_datasource: + community.grafana.grafana_datasource: name: datasource-loki grafana_url: "{{ grafana_url }}" grafana_user: "{{ grafana_username }}" - grafana_password: "{{ grafana_password}}" + grafana_password: "{{ grafana_password }}" state: absent -- debug: +- ansible.builtin.debug: var: result -- assert: +- ansible.builtin.assert: that: - - result.changed - - "result.msg == 'Datasource datasource-loki deleted.'" + - result.changed + - result.msg == 'Datasource datasource-loki deleted.' - name: Delete loki datasource (idempotency) register: result - grafana_datasource: + community.grafana.grafana_datasource: name: datasource-loki grafana_url: "{{ grafana_url }}" grafana_user: "{{ grafana_username }}" - grafana_password: "{{ grafana_password}}" + grafana_password: "{{ grafana_password }}" state: absent -- debug: +- ansible.builtin.debug: var: result -- assert: +- ansible.builtin.assert: that: - - not result.changed + - not result.changed diff --git a/tests/integration/targets/grafana_datasource/tasks/main.yml b/tests/integration/targets/grafana_datasource/tasks/main.yml index 312ad347..3813cae8 100644 --- a/tests/integration/targets/grafana_datasource/tasks/main.yml +++ b/tests/integration/targets/grafana_datasource/tasks/main.yml @@ -1,16 +1,13 @@ --- - - block: - - include_tasks: errors.yml - - include_tasks: elastic.yml - - include_tasks: influx.yml - - include_tasks: postgres.yml - - include_tasks: cloudwatch.yml - - include_tasks: thruk.yml - - include_tasks: loki.yml - - include_tasks: zabbix.yml - - include_tasks: redis.yml - - include_tasks: azure.yml - - include_tasks: uid.yml - -... + - ansible.builtin.include_tasks: errors.yml + - ansible.builtin.include_tasks: elastic.yml + - ansible.builtin.include_tasks: influx.yml + - ansible.builtin.include_tasks: postgres.yml + - ansible.builtin.include_tasks: cloudwatch.yml + - ansible.builtin.include_tasks: thruk.yml + - ansible.builtin.include_tasks: loki.yml + - ansible.builtin.include_tasks: zabbix.yml + - ansible.builtin.include_tasks: redis.yml + - ansible.builtin.include_tasks: azure.yml + - ansible.builtin.include_tasks: uid.yml diff --git a/tests/integration/targets/grafana_datasource/tasks/postgres.yml b/tests/integration/targets/grafana_datasource/tasks/postgres.yml index 80221f01..b07bc752 100644 --- a/tests/integration/targets/grafana_datasource/tasks/postgres.yml +++ b/tests/integration/targets/grafana_datasource/tasks/postgres.yml @@ -1,11 +1,12 @@ +--- - name: Create postgres datasource register: result - grafana_datasource: + community.grafana.grafana_datasource: name: datasource-postgres grafana_url: "{{ grafana_url }}" grafana_user: "{{ grafana_username }}" grafana_password: "{{ grafana_password }}" - org_id: '1' + org_id: "1" ds_type: postgres ds_url: postgres.company.com:5432 database: db @@ -15,22 +16,22 @@ additional_json_data: timescaledb: true -- debug: +- ansible.builtin.debug: var: result -- assert: +- ansible.builtin.assert: that: - - result.changed - - "result.msg == 'Datasource datasource-postgres created'" + - result.changed + - result.msg == 'Datasource datasource-postgres created' - name: Check postgres datasource creation idempotency register: result - grafana_datasource: + community.grafana.grafana_datasource: name: datasource-postgres grafana_url: "{{ grafana_url }}" grafana_user: "{{ grafana_username }}" grafana_password: "{{ grafana_password }}" - org_id: '1' + org_id: "1" ds_type: postgres ds_url: postgres.company.com:5432 database: db @@ -40,54 +41,54 @@ additional_json_data: timescaledb: true -- debug: +- ansible.builtin.debug: var: result -- assert: +- ansible.builtin.assert: that: - - not result.changed - - result.datasource.basicAuth == false - - result.datasource.database == 'db' - - result.datasource.isDefault == false - - result.datasource.jsonData.sslmode == 'verify-full' - - result.datasource.jsonData.tlsAuth == false - - result.datasource.jsonData.tlsAuthWithCACert == false - - result.datasource.jsonData.timescaledb == true - - result.datasource.name == 'datasource-postgres' - - result.datasource.orgId == 1 - - result.datasource.type == 'postgres' - - result.datasource.url == 'postgres.company.com:5432' - - result.datasource.user == 'postgres' - - result.datasource.withCredentials == false + - not result.changed + - result.datasource.basicAuth == false + - result.datasource.database == 'db' + - result.datasource.isDefault == false + - result.datasource.jsonData.sslmode == 'verify-full' + - result.datasource.jsonData.tlsAuth == false + - result.datasource.jsonData.tlsAuthWithCACert == false + - result.datasource.jsonData.timescaledb == true + - result.datasource.name == 'datasource-postgres' + - result.datasource.orgId == 1 + - result.datasource.type == 'postgres' + - result.datasource.url == 'postgres.company.com:5432' + - result.datasource.user == 'postgres' + - result.datasource.withCredentials == false - name: Delete postgres datasource register: result - grafana_datasource: + community.grafana.grafana_datasource: name: datasource-postgres grafana_url: "{{ grafana_url }}" grafana_user: "{{ grafana_username }}" grafana_password: "{{ grafana_password }}" state: absent -- debug: +- ansible.builtin.debug: var: result -- assert: +- ansible.builtin.assert: that: - - result.changed + - result.changed - name: Delete postgres datasource register: result - grafana_datasource: + community.grafana.grafana_datasource: name: datasource-postgres grafana_url: "{{ grafana_url }}" grafana_user: "{{ grafana_username }}" grafana_password: "{{ grafana_password }}" state: absent -- debug: +- ansible.builtin.debug: var: result -- assert: +- ansible.builtin.assert: that: - - not result.changed + - not result.changed diff --git a/tests/integration/targets/grafana_datasource/tasks/redis.yml b/tests/integration/targets/grafana_datasource/tasks/redis.yml index 93369535..dc39be64 100644 --- a/tests/integration/targets/grafana_datasource/tasks/redis.yml +++ b/tests/integration/targets/grafana_datasource/tasks/redis.yml @@ -1,101 +1,102 @@ +--- - name: Create redis datasource register: result - grafana_datasource: + community.grafana.grafana_datasource: name: datasource-redis grafana_url: "{{ grafana_url }}" grafana_user: "{{ grafana_username }}" grafana_password: "{{ grafana_password }}" - org_id: '1' + org_id: "1" ds_type: redis-datasource ds_url: https://redis.company.com:6379 time_interval: 1m -- debug: +- ansible.builtin.debug: var: result -- assert: +- ansible.builtin.assert: that: - - result.changed - - result.datasource.access == 'proxy' - - not result.datasource.isDefault - - result.datasource.name == 'datasource-redis' - - result.datasource.orgId == 1 - - result.datasource.type == 'redis-datasource' - - result.datasource.url == 'https://redis.company.com:6379' - - "result.msg == 'Datasource datasource-redis created'" + - result.changed + - result.datasource.access == 'proxy' + - not result.datasource.isDefault + - result.datasource.name == 'datasource-redis' + - result.datasource.orgId == 1 + - result.datasource.type == 'redis-datasource' + - result.datasource.url == 'https://redis.company.com:6379' + - result.msg == 'Datasource datasource-redis created' - name: Check redis-datasource datasource creation idempotency register: result - grafana_datasource: + community.grafana.grafana_datasource: name: datasource-redis grafana_url: "{{ grafana_url }}" grafana_user: "{{ grafana_username }}" grafana_password: "{{ grafana_password }}" - org_id: '1' + org_id: "1" ds_type: redis-datasource ds_url: https://redis.company.com:6379 time_interval: 1m -- debug: +- ansible.builtin.debug: var: result -- assert: +- ansible.builtin.assert: that: - - not result.changed - - result.datasource.access == 'proxy' - - not result.datasource.isDefault - - result.datasource.name == 'datasource-redis' - - result.datasource.orgId == 1 - - result.datasource.type == 'redis-datasource' - - result.datasource.url == 'https://redis.company.com:6379' + - not result.changed + - result.datasource.access == 'proxy' + - not result.datasource.isDefault + - result.datasource.name == 'datasource-redis' + - result.datasource.orgId == 1 + - result.datasource.type == 'redis-datasource' + - result.datasource.url == 'https://redis.company.com:6379' -- name: update redis-datasource datasource creation +- name: Update redis-datasource datasource creation register: result - grafana_datasource: + community.grafana.grafana_datasource: name: datasource-redis grafana_url: "{{ grafana_url }}" grafana_user: "{{ grafana_username }}" grafana_password: "{{ grafana_password }}" - org_id: '1' + org_id: "1" ds_type: redis-datasource ds_url: https://redisnew.company.com:6379 time_interval: 1m -- debug: +- ansible.builtin.debug: var: result -- assert: +- ansible.builtin.assert: that: - - result.changed - - result.datasource.access == 'proxy' - - not result.datasource.isDefault - - result.datasource.name == 'datasource-redis' - - result.datasource.orgId == 1 - - result.datasource.type == 'redis-datasource' - - result.datasource.url == 'https://redisnew.company.com:6379' + - result.changed + - result.datasource.access == 'proxy' + - not result.datasource.isDefault + - result.datasource.name == 'datasource-redis' + - result.datasource.orgId == 1 + - result.datasource.type == 'redis-datasource' + - result.datasource.url == 'https://redisnew.company.com:6379' -- name: Delete redis-datasource datasource +- name: Delete redis-datasource datasource register: result - grafana_datasource: + community.grafana.grafana_datasource: name: datasource-redis grafana_url: "{{ grafana_url }}" grafana_user: "{{ grafana_username }}" grafana_password: "{{ grafana_password }}" state: absent -- assert: +- ansible.builtin.assert: that: - - result.changed + - result.changed - name: Delete redis-datasource datasource (idempotency) register: result - grafana_datasource: + community.grafana.grafana_datasource: name: datasource-redis grafana_url: "{{ grafana_url }}" grafana_user: "{{ grafana_username }}" grafana_password: "{{ grafana_password }}" state: absent -- assert: +- ansible.builtin.assert: that: - - not result.changed + - not result.changed diff --git a/tests/integration/targets/grafana_datasource/tasks/thruk.yml b/tests/integration/targets/grafana_datasource/tasks/thruk.yml index 3ecc92d9..74f7c4df 100644 --- a/tests/integration/targets/grafana_datasource/tasks/thruk.yml +++ b/tests/integration/targets/grafana_datasource/tasks/thruk.yml @@ -1,78 +1,79 @@ +--- - name: Create thruk datasource register: result - grafana_datasource: + community.grafana.grafana_datasource: name: datasource-thruk grafana_url: "{{ grafana_url }}" grafana_user: "{{ grafana_username }}" grafana_password: "{{ grafana_password }}" org_id: "1" ds_type: sni-thruk-datasource - ds_url: "https://thruk.company.com/sitename/thruk" - tls_skip_verify: yes - validate_certs: no + ds_url: https://thruk.company.com/sitename/thruk + tls_skip_verify: true + validate_certs: false -- debug: +- ansible.builtin.debug: var: result -- assert: +- ansible.builtin.assert: that: - - result.changed - - "result.msg == 'Datasource datasource-thruk created'" + - result.changed + - result.msg == 'Datasource datasource-thruk created' - name: Check thruk datasource creation idempotency register: result - grafana_datasource: + community.grafana.grafana_datasource: name: datasource-thruk grafana_url: "{{ grafana_url }}" grafana_user: "{{ grafana_username }}" grafana_password: "{{ grafana_password }}" - org_id: '1' + org_id: "1" ds_type: sni-thruk-datasource - ds_url: "https://thruk.company.com/sitename/thruk" - tls_skip_verify: yes - validate_certs: no + ds_url: https://thruk.company.com/sitename/thruk + tls_skip_verify: true + validate_certs: false -- assert: +- ansible.builtin.assert: that: - - not result.changed - - result.datasource.basicAuth == false - - result.datasource.access == 'proxy' - - result.datasource.isDefault == false - - result.datasource.jsonData.tlsAuth == false - - result.datasource.jsonData.tlsAuthWithCACert == false - - result.datasource.name == 'datasource-thruk' - - result.datasource.orgId == 1 - - ('password' not in result.datasource) or (result.datasource.password == '') - - result.datasource.type == 'sni-thruk-datasource' - - result.datasource.url == 'https://thruk.company.com/sitename/thruk' - - result.datasource.user == '' - - result.datasource.withCredentials == false + - not result.changed + - result.datasource.basicAuth == false + - result.datasource.access == 'proxy' + - result.datasource.isDefault == false + - result.datasource.jsonData.tlsAuth == false + - result.datasource.jsonData.tlsAuthWithCACert == false + - result.datasource.name == 'datasource-thruk' + - result.datasource.orgId == 1 + - ('password' not in result.datasource) or (result.datasource.password == '') + - result.datasource.type == 'sni-thruk-datasource' + - result.datasource.url == 'https://thruk.company.com/sitename/thruk' + - result.datasource.user == '' + - result.datasource.withCredentials == false - name: Delete thruk datasource register: result - grafana_datasource: + community.grafana.grafana_datasource: name: datasource-thruk grafana_url: "{{ grafana_url }}" grafana_user: "{{ grafana_username }}" grafana_password: "{{ grafana_password }}" state: absent -- debug: +- ansible.builtin.debug: var: result -- assert: +- ansible.builtin.assert: that: - - result.changed + - result.changed - name: Delete thruk datasource (idempotency) register: result - grafana_datasource: + community.grafana.grafana_datasource: name: datasource-thruk grafana_url: "{{ grafana_url }}" grafana_user: "{{ grafana_username }}" grafana_password: "{{ grafana_password }}" state: absent -- assert: +- ansible.builtin.assert: that: - - not result.changed + - not result.changed diff --git a/tests/integration/targets/grafana_datasource/tasks/uid.yml b/tests/integration/targets/grafana_datasource/tasks/uid.yml index 71102a07..7a472b42 100644 --- a/tests/integration/targets/grafana_datasource/tasks/uid.yml +++ b/tests/integration/targets/grafana_datasource/tasks/uid.yml @@ -1,253 +1,254 @@ +--- - name: Create datasource with uid register: result - grafana_datasource: + community.grafana.grafana_datasource: name: datasource-with-uid uid: uid1 grafana_url: "{{ grafana_url }}" grafana_user: "{{ grafana_username }}" grafana_password: "{{ grafana_password }}" - org_id: '1' + org_id: "1" ds_type: prometheus ds_url: https://prometheus.company.com:8086 - basic_auth_user: "admin" - basic_auth_password: "admin" - validate_certs: False - is_default: no + basic_auth_user: admin + basic_auth_password: admin + validate_certs: false + is_default: false -- debug: +- ansible.builtin.debug: var: result -- assert: +- ansible.builtin.assert: that: - - result.changed - - "result.msg == 'Datasource datasource-with-uid created'" + - result.changed + - result.msg == 'Datasource datasource-with-uid created' - name: Create datasource without uid register: result - grafana_datasource: + community.grafana.grafana_datasource: name: datasource-without-uid grafana_url: "{{ grafana_url }}" grafana_user: "{{ grafana_username }}" grafana_password: "{{ grafana_password }}" - org_id: '1' + org_id: "1" ds_type: prometheus ds_url: https://prometheus.company.com:8086 - basic_auth_user: "admin" - basic_auth_password: "admin" - validate_certs: False - is_default: no + basic_auth_user: admin + basic_auth_password: admin + validate_certs: false + is_default: false -- debug: +- ansible.builtin.debug: var: result -- assert: +- ansible.builtin.assert: that: - - result.changed - - "result.msg == 'Datasource datasource-without-uid created'" + - result.changed + - result.msg == 'Datasource datasource-without-uid created' - name: Check datasource creation idempotency with uid register: result - grafana_datasource: + community.grafana.grafana_datasource: name: datasource-with-uid uid: uid1 grafana_url: "{{ grafana_url }}" grafana_user: "{{ grafana_username }}" grafana_password: "{{ grafana_password }}" - org_id: '1' + org_id: "1" ds_type: prometheus ds_url: https://prometheus.company.com:8086 - basic_auth_user: "admin" - basic_auth_password: "admin" - validate_certs: False - is_default: no + basic_auth_user: admin + basic_auth_password: admin + validate_certs: false + is_default: false -- debug: +- ansible.builtin.debug: var: result -- assert: +- ansible.builtin.assert: that: - - not result.changed - - result.datasource.access == 'proxy' - - result.datasource.isDefault == false - - result.datasource.jsonData.tlsAuth == false - - result.datasource.name == 'datasource-with-uid' - - result.datasource.uid == 'uid1' - - result.datasource.orgId == 1 - - ('password' not in result.datasource) or (result.datasource.password == '') - - result.datasource.type == 'prometheus' - - result.datasource.url == 'https://prometheus.company.com:8086' - - result.datasource.user == '' - - result.datasource.withCredentials == false + - not result.changed + - result.datasource.access == 'proxy' + - result.datasource.isDefault == false + - result.datasource.jsonData.tlsAuth == false + - result.datasource.name == 'datasource-with-uid' + - result.datasource.uid == 'uid1' + - result.datasource.orgId == 1 + - ('password' not in result.datasource) or (result.datasource.password == '') + - result.datasource.type == 'prometheus' + - result.datasource.url == 'https://prometheus.company.com:8086' + - result.datasource.user == '' + - result.datasource.withCredentials == false - name: Check datasource creation idempotency without uid register: result - grafana_datasource: + community.grafana.grafana_datasource: name: datasource-without-uid grafana_url: "{{ grafana_url }}" grafana_user: "{{ grafana_username }}" grafana_password: "{{ grafana_password }}" - org_id: '1' + org_id: "1" ds_type: prometheus ds_url: https://prometheus.company.com:8086 - basic_auth_user: "admin" - basic_auth_password: "admin" - validate_certs: False - is_default: no + basic_auth_user: admin + basic_auth_password: admin + validate_certs: false + is_default: false -- debug: +- ansible.builtin.debug: var: result -- assert: +- ansible.builtin.assert: that: - - not result.changed - - result.datasource.access == 'proxy' - - result.datasource.isDefault == false - - result.datasource.jsonData.tlsAuth == false - - result.datasource.name == 'datasource-without-uid' - - result.datasource.uid - - result.datasource.orgId == 1 - - ('password' not in result.datasource) or (result.datasource.password == '') - - result.datasource.type == 'prometheus' - - result.datasource.url == 'https://prometheus.company.com:8086' - - result.datasource.user == '' - - result.datasource.withCredentials == false + - not result.changed + - result.datasource.access == 'proxy' + - result.datasource.isDefault == false + - result.datasource.jsonData.tlsAuth == false + - result.datasource.name == 'datasource-without-uid' + - result.datasource.uid + - result.datasource.orgId == 1 + - ('password' not in result.datasource) or (result.datasource.password == '') + - result.datasource.type == 'prometheus' + - result.datasource.url == 'https://prometheus.company.com:8086' + - result.datasource.user == '' + - result.datasource.withCredentials == false - name: Set uid for datasource with random uid register: result - grafana_datasource: + community.grafana.grafana_datasource: name: datasource-without-uid uid: uid3 grafana_url: "{{ grafana_url }}" grafana_user: "{{ grafana_username }}" grafana_password: "{{ grafana_password }}" - org_id: '1' + org_id: "1" ds_type: prometheus ds_url: https://prometheus.company.com:8086 - basic_auth_user: "admin" - basic_auth_password: "admin" - validate_certs: False - is_default: no + basic_auth_user: admin + basic_auth_password: admin + validate_certs: false + is_default: false -- debug: +- ansible.builtin.debug: var: result -- assert: +- ansible.builtin.assert: that: - - result.changed - - result.datasource.access == 'proxy' - - result.datasource.isDefault == false - - result.datasource.jsonData.tlsAuth == false - - result.datasource.name == 'datasource-without-uid' - - result.datasource.uid == 'uid3' - - result.datasource.orgId == 1 - - ('password' not in result.datasource) or (result.datasource.password == '') - - result.datasource.type == 'prometheus' - - result.datasource.url == 'https://prometheus.company.com:8086' - - result.datasource.user == '' - - result.datasource.withCredentials == false + - result.changed + - result.datasource.access == 'proxy' + - result.datasource.isDefault == false + - result.datasource.jsonData.tlsAuth == false + - result.datasource.name == 'datasource-without-uid' + - result.datasource.uid == 'uid3' + - result.datasource.orgId == 1 + - ('password' not in result.datasource) or (result.datasource.password == '') + - result.datasource.type == 'prometheus' + - result.datasource.url == 'https://prometheus.company.com:8086' + - result.datasource.user == '' + - result.datasource.withCredentials == false - name: Change uid for datasource register: result - grafana_datasource: + community.grafana.grafana_datasource: name: datasource-with-uid uid: uid2 grafana_url: "{{ grafana_url }}" grafana_user: "{{ grafana_username }}" grafana_password: "{{ grafana_password }}" - org_id: '1' + org_id: "1" ds_type: prometheus ds_url: https://prometheus.company.com:8086 - basic_auth_user: "admin" - basic_auth_password: "admin" - validate_certs: False - is_default: no + basic_auth_user: admin + basic_auth_password: admin + validate_certs: false + is_default: false -- debug: +- ansible.builtin.debug: var: result -- assert: +- ansible.builtin.assert: that: - - result.changed - - result.datasource.access == 'proxy' - - result.datasource.isDefault == false - - result.datasource.jsonData.tlsAuth == false - - result.datasource.name == 'datasource-with-uid' - - result.datasource.uid == 'uid2' - - result.datasource.orgId == 1 - - ('password' not in result.datasource) or (result.datasource.password == '') - - result.datasource.type == 'prometheus' - - result.datasource.url == 'https://prometheus.company.com:8086' - - result.datasource.user == '' - - result.datasource.withCredentials == false + - result.changed + - result.datasource.access == 'proxy' + - result.datasource.isDefault == false + - result.datasource.jsonData.tlsAuth == false + - result.datasource.name == 'datasource-with-uid' + - result.datasource.uid == 'uid2' + - result.datasource.orgId == 1 + - ('password' not in result.datasource) or (result.datasource.password == '') + - result.datasource.type == 'prometheus' + - result.datasource.url == 'https://prometheus.company.com:8086' + - result.datasource.user == '' + - result.datasource.withCredentials == false - name: Delete datasource-with-uid register: result - grafana_datasource: + community.grafana.grafana_datasource: name: datasource-with-uid uid: uid1 grafana_url: "{{ grafana_url }}" grafana_user: "{{ grafana_username }}" grafana_password: "{{ grafana_password }}" - org_id: '1' + org_id: "1" ds_type: prometheus ds_url: https://prometheus.company.com:8086 - basic_auth_user: "admin" - basic_auth_password: "admin" - validate_certs: False - is_default: no + basic_auth_user: admin + basic_auth_password: admin + validate_certs: false + is_default: false state: absent -- debug: +- ansible.builtin.debug: var: result -- assert: +- ansible.builtin.assert: that: - - result.changed + - result.changed - name: Delete datasource-without-uid register: result - grafana_datasource: + community.grafana.grafana_datasource: name: datasource-without-uid grafana_url: "{{ grafana_url }}" grafana_user: "{{ grafana_username }}" grafana_password: "{{ grafana_password }}" - org_id: '1' + org_id: "1" ds_type: prometheus ds_url: https://prometheus.company.com:8086 - basic_auth_user: "admin" - basic_auth_password: "admin" - validate_certs: False - is_default: no + basic_auth_user: admin + basic_auth_password: admin + validate_certs: false + is_default: false state: absent -- debug: +- ansible.builtin.debug: var: result -- assert: +- ansible.builtin.assert: that: - - result.changed + - result.changed - name: Delete datasource-with-uid (idempotency) register: result - grafana_datasource: + community.grafana.grafana_datasource: name: datasource-with-uid uid: uid1 grafana_url: "{{ grafana_url }}" grafana_user: "{{ grafana_username }}" grafana_password: "{{ grafana_password }}" - org_id: '1' + org_id: "1" ds_type: prometheus ds_url: https://prometheus.company.com:8086 - basic_auth_user: "admin" - basic_auth_password: "admin" - validate_certs: False - is_default: no + basic_auth_user: admin + basic_auth_password: admin + validate_certs: false + is_default: false state: absent -- debug: +- ansible.builtin.debug: var: result -- assert: +- ansible.builtin.assert: that: - - not result.changed + - not result.changed diff --git a/tests/integration/targets/grafana_datasource/tasks/zabbix.yml b/tests/integration/targets/grafana_datasource/tasks/zabbix.yml index c8a8236b..d238efb3 100644 --- a/tests/integration/targets/grafana_datasource/tasks/zabbix.yml +++ b/tests/integration/targets/grafana_datasource/tasks/zabbix.yml @@ -1,114 +1,115 @@ +--- - name: Create zabbix datasource register: result - grafana_datasource: + community.grafana.grafana_datasource: name: datasource-zabbix grafana_url: "{{ grafana_url }}" grafana_user: "{{ grafana_username }}" grafana_password: "{{ grafana_password }}" - org_id: '1' + org_id: "1" ds_type: alexanderzobnin-zabbix-datasource ds_url: https://zabbix.company.com zabbix_user: grafana - zabbix_password: '******' + zabbix_password: "******" -- debug: +- ansible.builtin.debug: var: result -- assert: +- ansible.builtin.assert: that: - - result.changed - - not result.datasource.isDefault - - result.datasource.jsonData.username == 'grafana' - - result.datasource.name == 'datasource-zabbix' - - result.datasource.orgId == 1 - - ('password' not in result.datasource) or (result.datasource.password == '') - - result.datasource.type == 'alexanderzobnin-zabbix-datasource' - - result.datasource.url == 'https://zabbix.company.com' - - result.datasource.user == '' - - not result.datasource.withCredentials - - "result.msg == 'Datasource datasource-zabbix created'" + - result.changed + - not result.datasource.isDefault + - result.datasource.jsonData.username == 'grafana' + - result.datasource.name == 'datasource-zabbix' + - result.datasource.orgId == 1 + - ('password' not in result.datasource) or (result.datasource.password == '') + - result.datasource.type == 'alexanderzobnin-zabbix-datasource' + - result.datasource.url == 'https://zabbix.company.com' + - result.datasource.user == '' + - not result.datasource.withCredentials + - result.msg == 'Datasource datasource-zabbix created' - name: Create zabbix datasource (idempotency) register: result - grafana_datasource: + community.grafana.grafana_datasource: name: datasource-zabbix grafana_url: "{{ grafana_url }}" grafana_user: "{{ grafana_username }}" grafana_password: "{{ grafana_password }}" - org_id: '1' + org_id: "1" ds_type: alexanderzobnin-zabbix-datasource ds_url: https://zabbix.company.com zabbix_user: grafana - zabbix_password: '******' + zabbix_password: "******" -- debug: +- ansible.builtin.debug: var: result -- assert: +- ansible.builtin.assert: that: - - not result.changed - - not result.datasource.isDefault - - result.datasource.jsonData.username == 'grafana' - - result.datasource.name == 'datasource-zabbix' - - result.datasource.orgId == 1 - - ('password' not in result.datasource) or (result.datasource.password == '') - - result.datasource.type == 'alexanderzobnin-zabbix-datasource' - - result.datasource.url == 'https://zabbix.company.com' - - result.datasource.user == '' - - not result.datasource.withCredentials + - not result.changed + - not result.datasource.isDefault + - result.datasource.jsonData.username == 'grafana' + - result.datasource.name == 'datasource-zabbix' + - result.datasource.orgId == 1 + - ('password' not in result.datasource) or (result.datasource.password == '') + - result.datasource.type == 'alexanderzobnin-zabbix-datasource' + - result.datasource.url == 'https://zabbix.company.com' + - result.datasource.user == '' + - not result.datasource.withCredentials - name: Update zabbix datasource register: result - grafana_datasource: + community.grafana.grafana_datasource: name: datasource-zabbix grafana_url: "{{ grafana_url }}" grafana_user: "{{ grafana_username }}" grafana_password: "{{ grafana_password }}" - org_id: '1' + org_id: "1" ds_type: alexanderzobnin-zabbix-datasource ds_url: https://zabbix.example.com zabbix_user: grafana - zabbix_password: '******' + zabbix_password: "******" -- debug: +- ansible.builtin.debug: var: result -- assert: +- ansible.builtin.assert: that: - - result.changed - - not result.datasource.isDefault - - result.datasource.jsonData.username == 'grafana' - - result.datasource.name == 'datasource-zabbix' - - result.datasource.orgId == 1 - - ('password' not in result.datasource) or (result.datasource.password == '') - - result.datasource.type == 'alexanderzobnin-zabbix-datasource' - - result.datasource.url == 'https://zabbix.example.com' - - result.datasource.user == '' - - not result.datasource.withCredentials - - "result.msg == 'Datasource datasource-zabbix updated'" + - result.changed + - not result.datasource.isDefault + - result.datasource.jsonData.username == 'grafana' + - result.datasource.name == 'datasource-zabbix' + - result.datasource.orgId == 1 + - ('password' not in result.datasource) or (result.datasource.password == '') + - result.datasource.type == 'alexanderzobnin-zabbix-datasource' + - result.datasource.url == 'https://zabbix.example.com' + - result.datasource.user == '' + - not result.datasource.withCredentials + - result.msg == 'Datasource datasource-zabbix updated' - name: Delete zabbix datasource register: result - grafana_datasource: + community.grafana.grafana_datasource: name: datasource-zabbix grafana_url: "{{ grafana_url }}" grafana_user: "{{ grafana_username }}" grafana_password: "{{ grafana_password }}" state: absent -- assert: +- ansible.builtin.assert: that: - - result.changed + - result.changed - name: Delete zabbix datasource (idempotency) register: result - grafana_datasource: + community.grafana.grafana_datasource: name: datasource-zabbix grafana_url: "{{ grafana_url }}" grafana_user: "{{ grafana_username }}" grafana_password: "{{ grafana_password }}" state: absent -- assert: +- ansible.builtin.assert: that: - - not result.changed + - not result.changed diff --git a/tests/integration/targets/grafana_folder/defaults/main.yml b/tests/integration/targets/grafana_folder/defaults/main.yml index 8b9c9348..4abf9bb4 100644 --- a/tests/integration/targets/grafana_folder/defaults/main.yml +++ b/tests/integration/targets/grafana_folder/defaults/main.yml @@ -1,7 +1,5 @@ --- -grafana_url: "http://grafana:3000/" -grafana_username: "admin" -grafana_password: "admin" - -... +grafana_url: http://grafana:3000/ +grafana_username: admin +grafana_password: admin diff --git a/tests/integration/targets/grafana_folder/tasks/main.yml b/tests/integration/targets/grafana_folder/tasks/main.yml index c6a52056..cada94ab 100644 --- a/tests/integration/targets/grafana_folder/tasks/main.yml +++ b/tests/integration/targets/grafana_folder/tasks/main.yml @@ -1,55 +1,54 @@ --- - - name: Create a Folder grafana_folder: - url: "{{ grafana_url }}" - url_username: "{{ grafana_username }}" - url_password: "{{ grafana_password }}" - title: "grafana_working_group" - state: present + url: "{{ grafana_url }}" + url_username: "{{ grafana_username }}" + url_password: "{{ grafana_password }}" + title: grafana_working_group + state: present register: result -- assert: +- ansible.builtin.assert: that: - - "result.changed == true" - - "result.folder.title == 'grafana_working_group'" + - result.changed == true + - result.folder.title == 'grafana_working_group' - name: Test folder creation idempotency grafana_folder: - url: "{{ grafana_url }}" - url_username: "{{ grafana_username }}" - url_password: "{{ grafana_password }}" - title: "grafana_working_group" - state: present + url: "{{ grafana_url }}" + url_username: "{{ grafana_username }}" + url_password: "{{ grafana_password }}" + title: grafana_working_group + state: present register: result -- assert: +- ansible.builtin.assert: that: - - "result.changed == false" - - "result.folder.title == 'grafana_working_group'" + - result.changed == false + - result.folder.title == 'grafana_working_group' - name: Delete a Folder grafana_folder: - url: "{{ grafana_url }}" - url_username: "{{ grafana_username }}" - url_password: "{{ grafana_password }}" - title: "grafana_working_group" - state: absent + url: "{{ grafana_url }}" + url_username: "{{ grafana_username }}" + url_password: "{{ grafana_password }}" + title: grafana_working_group + state: absent register: result -- assert: +- ansible.builtin.assert: that: - - "result.changed == true" + - result.changed == true - name: Test folder deletion idempotency grafana_folder: - url: "{{ grafana_url }}" - url_username: "{{ grafana_username }}" - url_password: "{{ grafana_password }}" - title: "grafana_working_group" - state: absent + url: "{{ grafana_url }}" + url_username: "{{ grafana_username }}" + url_password: "{{ grafana_password }}" + title: grafana_working_group + state: absent register: result -- assert: +- ansible.builtin.assert: that: - - "result.changed == false" + - result.changed == false diff --git a/tests/integration/targets/grafana_notification_channel/defaults/main.yml b/tests/integration/targets/grafana_notification_channel/defaults/main.yml index 8b9c9348..4abf9bb4 100644 --- a/tests/integration/targets/grafana_notification_channel/defaults/main.yml +++ b/tests/integration/targets/grafana_notification_channel/defaults/main.yml @@ -1,7 +1,5 @@ --- -grafana_url: "http://grafana:3000/" -grafana_username: "admin" -grafana_password: "admin" - -... +grafana_url: http://grafana:3000/ +grafana_username: admin +grafana_password: admin diff --git a/tests/integration/targets/grafana_notification_channel/tasks/dingding.yml b/tests/integration/targets/grafana_notification_channel/tasks/dingding.yml index 7279e313..e6fb52b2 100644 --- a/tests/integration/targets/grafana_notification_channel/tasks/dingding.yml +++ b/tests/integration/targets/grafana_notification_channel/tasks/dingding.yml @@ -8,12 +8,12 @@ dingding_url: https://example.org grafana_url: "{{ grafana_url }}" grafana_user: "{{ grafana_username }}" - grafana_password: "{{ grafana_password}}" + grafana_password: "{{ grafana_password }}" -- debug: +- ansible.builtin.debug: var: result -- assert: +- ansible.builtin.assert: that: - result.changed == True - result.channel.name == "dingding" @@ -29,12 +29,12 @@ dingding_url: https://example.org grafana_url: "{{ grafana_url }}" grafana_user: "{{ grafana_username }}" - grafana_password: "{{ grafana_password}}" + grafana_password: "{{ grafana_password }}" -- debug: +- ansible.builtin.debug: var: result -- assert: +- ansible.builtin.assert: that: - result.changed == False - result.channel.name == "dingding" @@ -48,12 +48,12 @@ state: absent grafana_url: "{{ grafana_url }}" grafana_user: "{{ grafana_username }}" - grafana_password: "{{ grafana_password}}" + grafana_password: "{{ grafana_password }}" -- debug: +- ansible.builtin.debug: var: result -- assert: +- ansible.builtin.assert: that: - result.changed == True @@ -64,11 +64,11 @@ state: absent grafana_url: "{{ grafana_url }}" grafana_user: "{{ grafana_username }}" - grafana_password: "{{ grafana_password}}" + grafana_password: "{{ grafana_password }}" -- debug: +- ansible.builtin.debug: var: result -- assert: +- ansible.builtin.assert: that: - result.changed == False diff --git a/tests/integration/targets/grafana_notification_channel/tasks/discord.yml b/tests/integration/targets/grafana_notification_channel/tasks/discord.yml index 29cfece7..47141050 100644 --- a/tests/integration/targets/grafana_notification_channel/tasks/discord.yml +++ b/tests/integration/targets/grafana_notification_channel/tasks/discord.yml @@ -8,12 +8,12 @@ discord_url: https://example.org grafana_url: "{{ grafana_url }}" grafana_user: "{{ grafana_username }}" - grafana_password: "{{ grafana_password}}" + grafana_password: "{{ grafana_password }}" -- debug: +- ansible.builtin.debug: var: result -- assert: +- ansible.builtin.assert: that: - result.changed == True - result.channel.name == "discord" @@ -29,12 +29,12 @@ discord_url: https://example.org grafana_url: "{{ grafana_url }}" grafana_user: "{{ grafana_username }}" - grafana_password: "{{ grafana_password}}" + grafana_password: "{{ grafana_password }}" -- debug: +- ansible.builtin.debug: var: result -- assert: +- ansible.builtin.assert: that: - result.changed == False - result.channel.name == "discord" @@ -48,12 +48,12 @@ state: absent grafana_url: "{{ grafana_url }}" grafana_user: "{{ grafana_username }}" - grafana_password: "{{ grafana_password}}" + grafana_password: "{{ grafana_password }}" -- debug: +- ansible.builtin.debug: var: result -- assert: +- ansible.builtin.assert: that: - result.changed == True @@ -64,11 +64,11 @@ state: absent grafana_url: "{{ grafana_url }}" grafana_user: "{{ grafana_username }}" - grafana_password: "{{ grafana_password}}" + grafana_password: "{{ grafana_password }}" -- debug: +- ansible.builtin.debug: var: result -- assert: +- ansible.builtin.assert: that: - result.changed == False diff --git a/tests/integration/targets/grafana_notification_channel/tasks/email.yml b/tests/integration/targets/grafana_notification_channel/tasks/email.yml index 85a236c9..e5f91df1 100644 --- a/tests/integration/targets/grafana_notification_channel/tasks/email.yml +++ b/tests/integration/targets/grafana_notification_channel/tasks/email.yml @@ -10,14 +10,14 @@ - bar@example.org grafana_url: "{{ grafana_url }}" grafana_user: "{{ grafana_username }}" - grafana_password: "{{ grafana_password}}" + grafana_password: "{{ grafana_password }}" -- debug: +- ansible.builtin.debug: var: result -- assert: +- ansible.builtin.assert: that: - - "result.changed == True" + - result.changed == True - result.channel.name == "email" - result.channel.type == "email" - result.channel.uid == "email" @@ -33,14 +33,14 @@ - bar@example.org grafana_url: "{{ grafana_url }}" grafana_user: "{{ grafana_username }}" - grafana_password: "{{ grafana_password}}" + grafana_password: "{{ grafana_password }}" -- debug: +- ansible.builtin.debug: var: result -- assert: +- ansible.builtin.assert: that: - - "result.changed == False" + - result.changed == False - result.channel.name == "email" - result.channel.type == "email" - result.channel.uid == "email" @@ -52,15 +52,15 @@ state: absent grafana_url: "{{ grafana_url }}" grafana_user: "{{ grafana_username }}" - grafana_password: "{{ grafana_password}}" + grafana_password: "{{ grafana_password }}" -- debug: +- ansible.builtin.debug: var: result -- assert: +- ansible.builtin.assert: that: - - "result.changed == True" - - "result.state == 'absent'" + - result.changed == True + - result.state == 'absent' - name: Delete discord notification channel (idempotency) register: result @@ -69,11 +69,11 @@ state: absent grafana_url: "{{ grafana_url }}" grafana_user: "{{ grafana_username }}" - grafana_password: "{{ grafana_password}}" + grafana_password: "{{ grafana_password }}" -- debug: +- ansible.builtin.debug: var: result -- assert: +- ansible.builtin.assert: that: - - "result.changed == False" + - result.changed == False diff --git a/tests/integration/targets/grafana_notification_channel/tasks/googlechat.yml b/tests/integration/targets/grafana_notification_channel/tasks/googlechat.yml index abc7db64..be3b047b 100644 --- a/tests/integration/targets/grafana_notification_channel/tasks/googlechat.yml +++ b/tests/integration/targets/grafana_notification_channel/tasks/googlechat.yml @@ -8,14 +8,14 @@ googlechat_url: https://example.org grafana_url: "{{ grafana_url }}" grafana_user: "{{ grafana_username }}" - grafana_password: "{{ grafana_password}}" + grafana_password: "{{ grafana_password }}" -- debug: +- ansible.builtin.debug: var: result -- assert: +- ansible.builtin.assert: that: - - "result.changed == True" + - result.changed == True - result.channel.name == "googlechat" - result.channel.uid == "googlechat" - result.channel.type == "googlechat" @@ -29,14 +29,14 @@ googlechat_url: https://example.org grafana_url: "{{ grafana_url }}" grafana_user: "{{ grafana_username }}" - grafana_password: "{{ grafana_password}}" + grafana_password: "{{ grafana_password }}" -- debug: +- ansible.builtin.debug: var: result -- assert: +- ansible.builtin.assert: that: - - "result.changed == False" + - result.changed == False - result.channel.name == "googlechat" - result.channel.uid == "googlechat" - result.channel.type == "googlechat" @@ -48,14 +48,14 @@ state: absent grafana_url: "{{ grafana_url }}" grafana_user: "{{ grafana_username }}" - grafana_password: "{{ grafana_password}}" + grafana_password: "{{ grafana_password }}" -- debug: +- ansible.builtin.debug: var: result -- assert: +- ansible.builtin.assert: that: - - "result.changed == True" + - result.changed == True - name: Delete googlechat notification channel (idempotency) register: result @@ -64,11 +64,11 @@ state: absent grafana_url: "{{ grafana_url }}" grafana_user: "{{ grafana_username }}" - grafana_password: "{{ grafana_password}}" + grafana_password: "{{ grafana_password }}" -- debug: +- ansible.builtin.debug: var: result -- assert: +- ansible.builtin.assert: that: - - "result.changed == False" + - result.changed == False diff --git a/tests/integration/targets/grafana_notification_channel/tasks/hipchat.yml b/tests/integration/targets/grafana_notification_channel/tasks/hipchat.yml index 4a9ec170..7c95164e 100644 --- a/tests/integration/targets/grafana_notification_channel/tasks/hipchat.yml +++ b/tests/integration/targets/grafana_notification_channel/tasks/hipchat.yml @@ -8,14 +8,14 @@ hipchat_url: https://example.org grafana_url: "{{ grafana_url }}" grafana_user: "{{ grafana_username }}" - grafana_password: "{{ grafana_password}}" + grafana_password: "{{ grafana_password }}" -- debug: +- ansible.builtin.debug: var: result -- assert: +- ansible.builtin.assert: that: - - "result.changed == True" + - result.changed == True - result.channel.name == "hipchat" - result.channel.type == "hipchat" - result.channel.uid == "hipchat" @@ -29,14 +29,14 @@ hipchat_url: https://example.org grafana_url: "{{ grafana_url }}" grafana_user: "{{ grafana_username }}" - grafana_password: "{{ grafana_password}}" + grafana_password: "{{ grafana_password }}" -- debug: +- ansible.builtin.debug: var: result -- assert: +- ansible.builtin.assert: that: - - "result.changed == False" + - result.changed == False - result.channel.name == "hipchat" - result.channel.type == "hipchat" - result.channel.uid == "hipchat" @@ -48,14 +48,14 @@ state: absent grafana_url: "{{ grafana_url }}" grafana_user: "{{ grafana_username }}" - grafana_password: "{{ grafana_password}}" + grafana_password: "{{ grafana_password }}" -- debug: +- ansible.builtin.debug: var: result -- assert: +- ansible.builtin.assert: that: - - "result.changed == True" + - result.changed == True - name: Delete hipchat notification channel (idempotency) register: result @@ -64,11 +64,11 @@ state: absent grafana_url: "{{ grafana_url }}" grafana_user: "{{ grafana_username }}" - grafana_password: "{{ grafana_password}}" + grafana_password: "{{ grafana_password }}" -- debug: +- ansible.builtin.debug: var: result -- assert: +- ansible.builtin.assert: that: - - "result.changed == False" + - result.changed == False diff --git a/tests/integration/targets/grafana_notification_channel/tasks/kafka.yml b/tests/integration/targets/grafana_notification_channel/tasks/kafka.yml index ffc208ac..72440872 100644 --- a/tests/integration/targets/grafana_notification_channel/tasks/kafka.yml +++ b/tests/integration/targets/grafana_notification_channel/tasks/kafka.yml @@ -9,14 +9,14 @@ kafka_topic: test grafana_url: "{{ grafana_url }}" grafana_user: "{{ grafana_username }}" - grafana_password: "{{ grafana_password}}" + grafana_password: "{{ grafana_password }}" -- debug: +- ansible.builtin.debug: var: result -- assert: +- ansible.builtin.assert: that: - - "result.changed == True" + - result.changed == True - result.channel.name == "kafka" - result.channel.uid == "kafka" - result.channel.type == "kafka" @@ -31,14 +31,14 @@ kafka_topic: test grafana_url: "{{ grafana_url }}" grafana_user: "{{ grafana_username }}" - grafana_password: "{{ grafana_password}}" + grafana_password: "{{ grafana_password }}" -- debug: +- ansible.builtin.debug: var: result -- assert: +- ansible.builtin.assert: that: - - "result.changed == False" + - result.changed == False - result.channel.name == "kafka" - result.channel.uid == "kafka" - result.channel.type == "kafka" @@ -50,14 +50,14 @@ state: absent grafana_url: "{{ grafana_url }}" grafana_user: "{{ grafana_username }}" - grafana_password: "{{ grafana_password}}" + grafana_password: "{{ grafana_password }}" -- debug: +- ansible.builtin.debug: var: result -- assert: +- ansible.builtin.assert: that: - - "result.changed == True" + - result.changed == True - name: Delete kafka notification channel (idempotency) register: result @@ -66,11 +66,11 @@ state: absent grafana_url: "{{ grafana_url }}" grafana_user: "{{ grafana_username }}" - grafana_password: "{{ grafana_password}}" + grafana_password: "{{ grafana_password }}" -- debug: +- ansible.builtin.debug: var: result -- assert: +- ansible.builtin.assert: that: - - "result.changed == False" + - result.changed == False diff --git a/tests/integration/targets/grafana_notification_channel/tasks/line.yml b/tests/integration/targets/grafana_notification_channel/tasks/line.yml index 83a1863b..e985ef29 100644 --- a/tests/integration/targets/grafana_notification_channel/tasks/line.yml +++ b/tests/integration/targets/grafana_notification_channel/tasks/line.yml @@ -8,14 +8,14 @@ line_token: xxx grafana_url: "{{ grafana_url }}" grafana_user: "{{ grafana_username }}" - grafana_password: "{{ grafana_password}}" + grafana_password: "{{ grafana_password }}" -- debug: +- ansible.builtin.debug: var: result -- assert: +- ansible.builtin.assert: that: - - "result.changed == True" + - result.changed == True - result.channel.uid == "line" - result.channel.name == "line" - result.channel.type == "line" @@ -29,14 +29,14 @@ line_token: xxx grafana_url: "{{ grafana_url }}" grafana_user: "{{ grafana_username }}" - grafana_password: "{{ grafana_password}}" + grafana_password: "{{ grafana_password }}" -- debug: +- ansible.builtin.debug: var: result -- assert: +- ansible.builtin.assert: that: - - "result.changed == False" + - result.changed == False - result.channel.uid == "line" - result.channel.name == "line" - result.channel.type == "line" @@ -48,14 +48,14 @@ state: absent grafana_url: "{{ grafana_url }}" grafana_user: "{{ grafana_username }}" - grafana_password: "{{ grafana_password}}" + grafana_password: "{{ grafana_password }}" -- debug: +- ansible.builtin.debug: var: result -- assert: +- ansible.builtin.assert: that: - - "result.changed == True" + - result.changed == True - name: Delete line notification channel (idempotency) register: result @@ -64,11 +64,11 @@ state: absent grafana_url: "{{ grafana_url }}" grafana_user: "{{ grafana_username }}" - grafana_password: "{{ grafana_password}}" + grafana_password: "{{ grafana_password }}" -- debug: +- ansible.builtin.debug: var: result -- assert: +- ansible.builtin.assert: that: - - "result.changed == False" + - result.changed == False diff --git a/tests/integration/targets/grafana_notification_channel/tasks/main.yml b/tests/integration/targets/grafana_notification_channel/tasks/main.yml index ceaf72ad..f7468f85 100644 --- a/tests/integration/targets/grafana_notification_channel/tasks/main.yml +++ b/tests/integration/targets/grafana_notification_channel/tasks/main.yml @@ -1,20 +1,18 @@ --- - block: - - include_tasks: dingding.yml - - include_tasks: discord.yml - - include_tasks: email.yml - - include_tasks: googlechat.yml - - include_tasks: hipchat.yml - - include_tasks: kafka.yml -# - include_tasks: line.yml - - include_tasks: teams.yml - - include_tasks: opsgenie.yml - - include_tasks: pagerduty.yml - - include_tasks: prometheus.yml - - include_tasks: pushover.yml - - include_tasks: sensu.yml - - include_tasks: slack-and-beyond.yml - - include_tasks: telegram.yml -# - include_tasks: threema.yml - - include_tasks: victorops.yml - - include_tasks: webhook.yml + - ansible.builtin.include_tasks: dingding.yml + - ansible.builtin.include_tasks: discord.yml + - ansible.builtin.include_tasks: email.yml + - ansible.builtin.include_tasks: googlechat.yml + - ansible.builtin.include_tasks: hipchat.yml + - ansible.builtin.include_tasks: kafka.yml + - ansible.builtin.include_tasks: teams.yml + - ansible.builtin.include_tasks: opsgenie.yml + - ansible.builtin.include_tasks: pagerduty.yml + - ansible.builtin.include_tasks: prometheus.yml + - ansible.builtin.include_tasks: pushover.yml + - ansible.builtin.include_tasks: sensu.yml + - ansible.builtin.include_tasks: slack-and-beyond.yml + - ansible.builtin.include_tasks: telegram.yml + - ansible.builtin.include_tasks: victorops.yml + - ansible.builtin.include_tasks: webhook.yml diff --git a/tests/integration/targets/grafana_notification_channel/tasks/opsgenie.yml b/tests/integration/targets/grafana_notification_channel/tasks/opsgenie.yml index f871fe71..3c833a56 100644 --- a/tests/integration/targets/grafana_notification_channel/tasks/opsgenie.yml +++ b/tests/integration/targets/grafana_notification_channel/tasks/opsgenie.yml @@ -9,14 +9,14 @@ opsgenie_api_key: xxx grafana_url: "{{ grafana_url }}" grafana_user: "{{ grafana_username }}" - grafana_password: "{{ grafana_password}}" + grafana_password: "{{ grafana_password }}" -- debug: +- ansible.builtin.debug: var: result -- assert: +- ansible.builtin.assert: that: - - "result.changed == True" + - result.changed == True - result.channel.name == "opsgenie" - result.channel.type == "opsgenie" - result.channel.uid == "opsgenie" @@ -31,14 +31,14 @@ opsgenie_api_key: xxx grafana_url: "{{ grafana_url }}" grafana_user: "{{ grafana_username }}" - grafana_password: "{{ grafana_password}}" + grafana_password: "{{ grafana_password }}" -- debug: +- ansible.builtin.debug: var: result -- assert: +- ansible.builtin.assert: that: - - "result.changed == False" + - result.changed == False - result.channel.name == "opsgenie" - result.channel.type == "opsgenie" - result.channel.uid == "opsgenie" @@ -50,15 +50,15 @@ state: absent grafana_url: "{{ grafana_url }}" grafana_user: "{{ grafana_username }}" - grafana_password: "{{ grafana_password}}" + grafana_password: "{{ grafana_password }}" -- debug: +- ansible.builtin.debug: var: result -- assert: +- ansible.builtin.assert: that: - - "result.changed == True" - - "result.state == 'absent'" + - result.changed == True + - result.state == 'absent' - name: Delete opsgenie notification channel (idempotency) register: result @@ -67,11 +67,11 @@ state: absent grafana_url: "{{ grafana_url }}" grafana_user: "{{ grafana_username }}" - grafana_password: "{{ grafana_password}}" + grafana_password: "{{ grafana_password }}" -- debug: +- ansible.builtin.debug: var: result -- assert: +- ansible.builtin.assert: that: - - "result.changed == False" + - result.changed == False diff --git a/tests/integration/targets/grafana_notification_channel/tasks/pagerduty.yml b/tests/integration/targets/grafana_notification_channel/tasks/pagerduty.yml index a8fa940b..19cd2d59 100644 --- a/tests/integration/targets/grafana_notification_channel/tasks/pagerduty.yml +++ b/tests/integration/targets/grafana_notification_channel/tasks/pagerduty.yml @@ -8,14 +8,14 @@ pagerduty_integration_key: xxx grafana_url: "{{ grafana_url }}" grafana_user: "{{ grafana_username }}" - grafana_password: "{{ grafana_password}}" + grafana_password: "{{ grafana_password }}" -- debug: +- ansible.builtin.debug: var: result -- assert: +- ansible.builtin.assert: that: - - "result.changed == True" + - result.changed == True - result.channel.name == "pagerduty" - result.channel.type == "pagerduty" - result.channel.uid == "pagerduty" @@ -29,14 +29,14 @@ pagerduty_integration_key: xxx grafana_url: "{{ grafana_url }}" grafana_user: "{{ grafana_username }}" - grafana_password: "{{ grafana_password}}" + grafana_password: "{{ grafana_password }}" -- debug: +- ansible.builtin.debug: var: result -- assert: +- ansible.builtin.assert: that: - - "result.changed == False" + - result.changed == False - result.channel.name == "pagerduty" - result.channel.type == "pagerduty" - result.channel.uid == "pagerduty" @@ -48,14 +48,14 @@ state: absent grafana_url: "{{ grafana_url }}" grafana_user: "{{ grafana_username }}" - grafana_password: "{{ grafana_password}}" + grafana_password: "{{ grafana_password }}" -- debug: +- ansible.builtin.debug: var: result -- assert: +- ansible.builtin.assert: that: - - "result.changed == True" + - result.changed == True - name: Delete pagerduty notification channel (idempotency) register: result @@ -64,11 +64,11 @@ state: absent grafana_url: "{{ grafana_url }}" grafana_user: "{{ grafana_username }}" - grafana_password: "{{ grafana_password}}" + grafana_password: "{{ grafana_password }}" -- debug: +- ansible.builtin.debug: var: result -- assert: +- ansible.builtin.assert: that: - - "result.changed == False" + - result.changed == False diff --git a/tests/integration/targets/grafana_notification_channel/tasks/prometheus.yml b/tests/integration/targets/grafana_notification_channel/tasks/prometheus.yml index 40810eaf..dcce5674 100644 --- a/tests/integration/targets/grafana_notification_channel/tasks/prometheus.yml +++ b/tests/integration/targets/grafana_notification_channel/tasks/prometheus.yml @@ -8,14 +8,14 @@ prometheus_url: https://example.org grafana_url: "{{ grafana_url }}" grafana_user: "{{ grafana_username }}" - grafana_password: "{{ grafana_password}}" + grafana_password: "{{ grafana_password }}" -- debug: +- ansible.builtin.debug: var: result -- assert: +- ansible.builtin.assert: that: - - "result.changed == True" + - result.changed == True - result.channel.name == "prometheus" - result.channel.uid == "prometheus" - result.channel.type == "prometheus-alertmanager" @@ -29,14 +29,14 @@ prometheus_url: https://example.org grafana_url: "{{ grafana_url }}" grafana_user: "{{ grafana_username }}" - grafana_password: "{{ grafana_password}}" + grafana_password: "{{ grafana_password }}" -- debug: +- ansible.builtin.debug: var: result -- assert: +- ansible.builtin.assert: that: - - "result.changed == False" + - result.changed == False - result.channel.name == "prometheus" - result.channel.uid == "prometheus" - result.channel.type == "prometheus-alertmanager" @@ -48,14 +48,14 @@ state: absent grafana_url: "{{ grafana_url }}" grafana_user: "{{ grafana_username }}" - grafana_password: "{{ grafana_password}}" + grafana_password: "{{ grafana_password }}" -- debug: +- ansible.builtin.debug: var: result -- assert: +- ansible.builtin.assert: that: - - "result.changed == True" + - result.changed == True - name: Delete prometheus notification channel (idempotency) register: result @@ -64,11 +64,11 @@ state: absent grafana_url: "{{ grafana_url }}" grafana_user: "{{ grafana_username }}" - grafana_password: "{{ grafana_password}}" + grafana_password: "{{ grafana_password }}" -- debug: +- ansible.builtin.debug: var: result -- assert: +- ansible.builtin.assert: that: - - "result.changed == False" + - result.changed == False diff --git a/tests/integration/targets/grafana_notification_channel/tasks/pushover.yml b/tests/integration/targets/grafana_notification_channel/tasks/pushover.yml index 894bd71e..02743f70 100644 --- a/tests/integration/targets/grafana_notification_channel/tasks/pushover.yml +++ b/tests/integration/targets/grafana_notification_channel/tasks/pushover.yml @@ -9,14 +9,14 @@ pushover_user_key: yyy grafana_url: "{{ grafana_url }}" grafana_user: "{{ grafana_username }}" - grafana_password: "{{ grafana_password}}" + grafana_password: "{{ grafana_password }}" -- debug: +- ansible.builtin.debug: var: result -- assert: +- ansible.builtin.assert: that: - - "result.changed == True" + - result.changed == True - result.channel.name == "pushover" - result.channel.uid == "pushover" - result.channel.type == "pushover" @@ -31,14 +31,14 @@ pushover_user_key: yyy grafana_url: "{{ grafana_url }}" grafana_user: "{{ grafana_username }}" - grafana_password: "{{ grafana_password}}" + grafana_password: "{{ grafana_password }}" -- debug: +- ansible.builtin.debug: var: result -- assert: +- ansible.builtin.assert: that: - - "result.changed == False" + - result.changed == False - result.channel.name == "pushover" - result.channel.uid == "pushover" - result.channel.type == "pushover" @@ -50,14 +50,14 @@ state: absent grafana_url: "{{ grafana_url }}" grafana_user: "{{ grafana_username }}" - grafana_password: "{{ grafana_password}}" + grafana_password: "{{ grafana_password }}" -- debug: +- ansible.builtin.debug: var: result -- assert: +- ansible.builtin.assert: that: - - "result.changed == True" + - result.changed == True - name: Delete pushover notification channel (idempotency) register: result @@ -66,11 +66,11 @@ state: absent grafana_url: "{{ grafana_url }}" grafana_user: "{{ grafana_username }}" - grafana_password: "{{ grafana_password}}" + grafana_password: "{{ grafana_password }}" -- debug: +- ansible.builtin.debug: var: result -- assert: +- ansible.builtin.assert: that: - - "result.changed == False" + - result.changed == False diff --git a/tests/integration/targets/grafana_notification_channel/tasks/sensu.yml b/tests/integration/targets/grafana_notification_channel/tasks/sensu.yml index 01619b71..5fc87e71 100644 --- a/tests/integration/targets/grafana_notification_channel/tasks/sensu.yml +++ b/tests/integration/targets/grafana_notification_channel/tasks/sensu.yml @@ -8,14 +8,14 @@ sensu_url: https://example.org grafana_url: "{{ grafana_url }}" grafana_user: "{{ grafana_username }}" - grafana_password: "{{ grafana_password}}" + grafana_password: "{{ grafana_password }}" -- debug: +- ansible.builtin.debug: var: result -- assert: +- ansible.builtin.assert: that: - - "result.changed == True" + - result.changed == True - result.channel.name == "sensu" - result.channel.type == "sensu" - result.channel.uid == "sensu" @@ -29,14 +29,14 @@ sensu_url: https://example.org grafana_url: "{{ grafana_url }}" grafana_user: "{{ grafana_username }}" - grafana_password: "{{ grafana_password}}" + grafana_password: "{{ grafana_password }}" -- debug: +- ansible.builtin.debug: var: result -- assert: +- ansible.builtin.assert: that: - - "result.changed == False" + - result.changed == False - result.channel.name == "sensu" - result.channel.type == "sensu" - result.channel.uid == "sensu" @@ -48,14 +48,14 @@ state: absent grafana_url: "{{ grafana_url }}" grafana_user: "{{ grafana_username }}" - grafana_password: "{{ grafana_password}}" + grafana_password: "{{ grafana_password }}" -- debug: +- ansible.builtin.debug: var: result -- assert: +- ansible.builtin.assert: that: - - "result.changed == True" + - result.changed == True - name: Delete sensu notification channel (idempotency) register: result @@ -64,11 +64,11 @@ state: absent grafana_url: "{{ grafana_url }}" grafana_user: "{{ grafana_username }}" - grafana_password: "{{ grafana_password}}" + grafana_password: "{{ grafana_password }}" -- debug: +- ansible.builtin.debug: var: result -- assert: +- ansible.builtin.assert: that: - - "result.changed == False" + - result.changed == False diff --git a/tests/integration/targets/grafana_notification_channel/tasks/slack-and-beyond.yml b/tests/integration/targets/grafana_notification_channel/tasks/slack-and-beyond.yml index 0748c8bd..15f77051 100644 --- a/tests/integration/targets/grafana_notification_channel/tasks/slack-and-beyond.yml +++ b/tests/integration/targets/grafana_notification_channel/tasks/slack-and-beyond.yml @@ -8,14 +8,14 @@ slack_url: https://hooks.slack.com/services/xxx/yyy/zzz grafana_url: "{{ grafana_url }}" grafana_user: "{{ grafana_username }}" - grafana_password: "{{ grafana_password}}" + grafana_password: "{{ grafana_password }}" -- debug: +- ansible.builtin.debug: var: result -- assert: +- ansible.builtin.assert: that: - - "result.changed == True" + - result.changed == True - result.channel.name == "slack" - result.channel.type == "slack" - result.channel.uid == "slack" @@ -29,14 +29,14 @@ slack_url: https://hooks.slack.com/services/xxx/yyy/zzz grafana_url: "{{ grafana_url }}" grafana_user: "{{ grafana_username }}" - grafana_password: "{{ grafana_password}}" + grafana_password: "{{ grafana_password }}" -- debug: +- ansible.builtin.debug: var: result -- assert: +- ansible.builtin.assert: that: - - "result.changed == False" + - result.changed == False - result.channel.name == "slack" - result.channel.type == "slack" - result.channel.uid == "slack" @@ -50,14 +50,14 @@ slack_url: https://hooks.slack.com/services/xxx/yyy/zzz grafana_url: "{{ grafana_url }}" grafana_user: "{{ grafana_username }}" - grafana_password: "{{ grafana_password}}" + grafana_password: "{{ grafana_password }}" -- debug: +- ansible.builtin.debug: var: result -- assert: +- ansible.builtin.assert: that: - - "result.changed == False" + - result.changed == False - name: Update slack notification channel register: result @@ -68,14 +68,14 @@ slack_url: https://hooks.slack.com/services/xxx/yyy/fff grafana_url: "{{ grafana_url }}" grafana_user: "{{ grafana_username }}" - grafana_password: "{{ grafana_password}}" + grafana_password: "{{ grafana_password }}" -- debug: +- ansible.builtin.debug: var: result -- assert: +- ansible.builtin.assert: that: - - "result.changed == True" + - result.changed == True - name: Delete slack notification channel register: result @@ -84,14 +84,14 @@ uid: slack grafana_url: "{{ grafana_url }}" grafana_user: "{{ grafana_username }}" - grafana_password: "{{ grafana_password}}" + grafana_password: "{{ grafana_password }}" -- debug: +- ansible.builtin.debug: var: result -- assert: +- ansible.builtin.assert: that: - - "result.changed == True" + - result.changed == True - name: Delete slack notification channel (idempotency) register: result @@ -100,11 +100,11 @@ uid: slack grafana_url: "{{ grafana_url }}" grafana_user: "{{ grafana_username }}" - grafana_password: "{{ grafana_password}}" + grafana_password: "{{ grafana_password }}" -- debug: +- ansible.builtin.debug: var: result -- assert: +- ansible.builtin.assert: that: - - "result.changed == False" + - result.changed == False diff --git a/tests/integration/targets/grafana_notification_channel/tasks/teams.yml b/tests/integration/targets/grafana_notification_channel/tasks/teams.yml index cfc44aef..f7cee7da 100644 --- a/tests/integration/targets/grafana_notification_channel/tasks/teams.yml +++ b/tests/integration/targets/grafana_notification_channel/tasks/teams.yml @@ -8,14 +8,14 @@ teams_url: https://example.org grafana_url: "{{ grafana_url }}" grafana_user: "{{ grafana_username }}" - grafana_password: "{{ grafana_password}}" + grafana_password: "{{ grafana_password }}" -- debug: +- ansible.builtin.debug: var: result -- assert: +- ansible.builtin.assert: that: - - "result.changed == True" + - result.changed == True - result.channel.name == "teams" - result.channel.uid == "teams" - result.channel.type == "teams" @@ -29,14 +29,14 @@ teams_url: https://example.org grafana_url: "{{ grafana_url }}" grafana_user: "{{ grafana_username }}" - grafana_password: "{{ grafana_password}}" + grafana_password: "{{ grafana_password }}" -- debug: +- ansible.builtin.debug: var: result -- assert: +- ansible.builtin.assert: that: - - "result.changed == False" + - result.changed == False - result.channel.name == "teams" - result.channel.uid == "teams" - result.channel.type == "teams" @@ -48,14 +48,14 @@ state: absent grafana_url: "{{ grafana_url }}" grafana_user: "{{ grafana_username }}" - grafana_password: "{{ grafana_password}}" + grafana_password: "{{ grafana_password }}" -- debug: +- ansible.builtin.debug: var: result -- assert: +- ansible.builtin.assert: that: - - "result.changed == True" + - result.changed == True - name: Delete teams notification channel (idempotency) register: result @@ -64,11 +64,11 @@ state: absent grafana_url: "{{ grafana_url }}" grafana_user: "{{ grafana_username }}" - grafana_password: "{{ grafana_password}}" + grafana_password: "{{ grafana_password }}" -- debug: +- ansible.builtin.debug: var: result -- assert: +- ansible.builtin.assert: that: - - "result.changed == False" + - result.changed == False diff --git a/tests/integration/targets/grafana_notification_channel/tasks/telegram.yml b/tests/integration/targets/grafana_notification_channel/tasks/telegram.yml index 98a7a3c6..90941ce4 100644 --- a/tests/integration/targets/grafana_notification_channel/tasks/telegram.yml +++ b/tests/integration/targets/grafana_notification_channel/tasks/telegram.yml @@ -9,14 +9,14 @@ telegram_chat_id: yyy grafana_url: "{{ grafana_url }}" grafana_user: "{{ grafana_username }}" - grafana_password: "{{ grafana_password}}" + grafana_password: "{{ grafana_password }}" -- debug: +- ansible.builtin.debug: var: result -- assert: +- ansible.builtin.assert: that: - - "result.changed == True" + - result.changed == True - result.channel.name == "telegram" - result.channel.type == "telegram" - result.channel.uid == "telegram" @@ -31,14 +31,14 @@ telegram_chat_id: yyy grafana_url: "{{ grafana_url }}" grafana_user: "{{ grafana_username }}" - grafana_password: "{{ grafana_password}}" + grafana_password: "{{ grafana_password }}" -- debug: +- ansible.builtin.debug: var: result -- assert: +- ansible.builtin.assert: that: - - "result.changed == False" + - result.changed == False - result.channel.name == "telegram" - result.channel.type == "telegram" - result.channel.uid == "telegram" @@ -50,14 +50,14 @@ state: absent grafana_url: "{{ grafana_url }}" grafana_user: "{{ grafana_username }}" - grafana_password: "{{ grafana_password}}" + grafana_password: "{{ grafana_password }}" -- debug: +- ansible.builtin.debug: var: result -- assert: +- ansible.builtin.assert: that: - - "result.changed == True" + - result.changed == True - name: Delete telegram notification channel (idempotency) register: result @@ -66,11 +66,11 @@ state: absent grafana_url: "{{ grafana_url }}" grafana_user: "{{ grafana_username }}" - grafana_password: "{{ grafana_password}}" + grafana_password: "{{ grafana_password }}" -- debug: +- ansible.builtin.debug: var: result -- assert: +- ansible.builtin.assert: that: - - "result.changed == False" + - result.changed == False diff --git a/tests/integration/targets/grafana_notification_channel/tasks/threema.yml b/tests/integration/targets/grafana_notification_channel/tasks/threema.yml index 7858b697..141eaeae 100644 --- a/tests/integration/targets/grafana_notification_channel/tasks/threema.yml +++ b/tests/integration/targets/grafana_notification_channel/tasks/threema.yml @@ -10,14 +10,14 @@ threema_api_secret: zzz grafana_url: "{{ grafana_url }}" grafana_user: "{{ grafana_username }}" - grafana_password: "{{ grafana_password}}" + grafana_password: "{{ grafana_password }}" -- debug: +- ansible.builtin.debug: var: result -- assert: +- ansible.builtin.assert: that: - - "result.changed == True" + - result.changed == True - result.channel.name == "threema" - result.channel.type == "threema" - result.channel.uid == "threema" @@ -33,14 +33,14 @@ threema_api_secret: zzz grafana_url: "{{ grafana_url }}" grafana_user: "{{ grafana_username }}" - grafana_password: "{{ grafana_password}}" + grafana_password: "{{ grafana_password }}" -- debug: +- ansible.builtin.debug: var: result -- assert: +- ansible.builtin.assert: that: - - "result.changed == True" + - result.changed == True - result.channel.name == "threema" - result.channel.type == "threema" - result.channel.uid == "threema" @@ -52,14 +52,14 @@ state: absent grafana_url: "{{ grafana_url }}" grafana_user: "{{ grafana_username }}" - grafana_password: "{{ grafana_password}}" + grafana_password: "{{ grafana_password }}" -- debug: +- ansible.builtin.debug: var: result -- assert: +- ansible.builtin.assert: that: - - "result.changed == True" + - result.changed == True - name: Delete threema notification channel (idempotency) register: result @@ -68,11 +68,11 @@ state: absent grafana_url: "{{ grafana_url }}" grafana_user: "{{ grafana_username }}" - grafana_password: "{{ grafana_password}}" + grafana_password: "{{ grafana_password }}" -- debug: +- ansible.builtin.debug: var: result -- assert: +- ansible.builtin.assert: that: - - "result.changed == False" + - result.changed == False diff --git a/tests/integration/targets/grafana_notification_channel/tasks/victorops.yml b/tests/integration/targets/grafana_notification_channel/tasks/victorops.yml index 3779e813..c0f34d7c 100644 --- a/tests/integration/targets/grafana_notification_channel/tasks/victorops.yml +++ b/tests/integration/targets/grafana_notification_channel/tasks/victorops.yml @@ -8,14 +8,14 @@ victorops_url: https://example.org grafana_url: "{{ grafana_url }}" grafana_user: "{{ grafana_username }}" - grafana_password: "{{ grafana_password}}" + grafana_password: "{{ grafana_password }}" -- debug: +- ansible.builtin.debug: var: result -- assert: +- ansible.builtin.assert: that: - - "result.changed == True" + - result.changed == True - result.channel.name == "victorops" - result.channel.type == "victorops" - result.channel.uid == "victorops" @@ -29,14 +29,14 @@ victorops_url: https://example.org grafana_url: "{{ grafana_url }}" grafana_user: "{{ grafana_username }}" - grafana_password: "{{ grafana_password}}" + grafana_password: "{{ grafana_password }}" -- debug: +- ansible.builtin.debug: var: result -- assert: +- ansible.builtin.assert: that: - - "result.changed == False" + - result.changed == False - result.channel.name == "victorops" - result.channel.type == "victorops" - result.channel.uid == "victorops" @@ -48,14 +48,14 @@ state: absent grafana_url: "{{ grafana_url }}" grafana_user: "{{ grafana_username }}" - grafana_password: "{{ grafana_password}}" + grafana_password: "{{ grafana_password }}" -- debug: +- ansible.builtin.debug: var: result -- assert: +- ansible.builtin.assert: that: - - "result.changed == True" + - result.changed == True - name: Delete victorops notification channel (idempotency) register: result @@ -64,11 +64,11 @@ state: absent grafana_url: "{{ grafana_url }}" grafana_user: "{{ grafana_username }}" - grafana_password: "{{ grafana_password}}" + grafana_password: "{{ grafana_password }}" -- debug: +- ansible.builtin.debug: var: result -- assert: +- ansible.builtin.assert: that: - - "result.changed == False" + - result.changed == False diff --git a/tests/integration/targets/grafana_notification_channel/tasks/webhook.yml b/tests/integration/targets/grafana_notification_channel/tasks/webhook.yml index c9efd919..39bce110 100644 --- a/tests/integration/targets/grafana_notification_channel/tasks/webhook.yml +++ b/tests/integration/targets/grafana_notification_channel/tasks/webhook.yml @@ -8,14 +8,14 @@ webhook_url: https://example.org grafana_url: "{{ grafana_url }}" grafana_user: "{{ grafana_username }}" - grafana_password: "{{ grafana_password}}" + grafana_password: "{{ grafana_password }}" -- debug: +- ansible.builtin.debug: var: result -- assert: +- ansible.builtin.assert: that: - - "result.changed == True" + - result.changed == True - result.channel.name == "webhook" - result.channel.uid == "webhook" - result.channel.type == "webhook" @@ -29,14 +29,14 @@ webhook_url: https://example.org grafana_url: "{{ grafana_url }}" grafana_user: "{{ grafana_username }}" - grafana_password: "{{ grafana_password}}" + grafana_password: "{{ grafana_password }}" -- debug: +- ansible.builtin.debug: var: result -- assert: +- ansible.builtin.assert: that: - - "result.changed == False" + - result.changed == False - result.channel.name == "webhook" - result.channel.uid == "webhook" - result.channel.type == "webhook" @@ -48,14 +48,14 @@ state: absent grafana_url: "{{ grafana_url }}" grafana_user: "{{ grafana_username }}" - grafana_password: "{{ grafana_password}}" + grafana_password: "{{ grafana_password }}" -- debug: +- ansible.builtin.debug: var: result -- assert: +- ansible.builtin.assert: that: - - "result.changed == True" + - result.changed == True - name: Delete webhook notification channel (idempotency) register: result @@ -64,11 +64,11 @@ state: absent grafana_url: "{{ grafana_url }}" grafana_user: "{{ grafana_username }}" - grafana_password: "{{ grafana_password}}" + grafana_password: "{{ grafana_password }}" -- debug: +- ansible.builtin.debug: var: result -- assert: +- ansible.builtin.assert: that: - - "result.changed == False" + - result.changed == False diff --git a/tests/integration/targets/grafana_organization/defaults/main.yml b/tests/integration/targets/grafana_organization/defaults/main.yml index 7bb77ea3..3edac859 100644 --- a/tests/integration/targets/grafana_organization/defaults/main.yml +++ b/tests/integration/targets/grafana_organization/defaults/main.yml @@ -1,4 +1,4 @@ --- -grafana_url: "http://grafana:3000/" -grafana_username: "admin" -grafana_password: "admin" +grafana_url: http://grafana:3000/ +grafana_username: admin +grafana_password: admin diff --git a/tests/integration/targets/grafana_organization/tasks/main.yml b/tests/integration/targets/grafana_organization/tasks/main.yml index f8ccdf3b..156bc940 100644 --- a/tests/integration/targets/grafana_organization/tasks/main.yml +++ b/tests/integration/targets/grafana_organization/tasks/main.yml @@ -1,5 +1,4 @@ --- - - name: Create a Grafana organization community.grafana.grafana_organization: url: "{{ grafana_url }}" @@ -8,13 +7,13 @@ name: orgtest state: present register: result -- assert: +- ansible.builtin.assert: that: - - "result.changed == true" - - "result.failed == false" - - "result.org.name == 'orgtest'" + - result.changed == true + - result.failed == false + - result.org.name == 'orgtest' -- name: check idempotency Grafana organization +- name: Check idempotency Grafana organization community.grafana.grafana_organization: url: "{{ grafana_url }}" url_username: "{{ grafana_username }}" @@ -22,11 +21,11 @@ name: orgtest state: present register: result -- assert: +- ansible.builtin.assert: that: - - "result.changed == false" - - "result.failed == false" - - "result.org.name == 'orgtest'" + - result.changed == false + - result.failed == false + - result.org.name == 'orgtest' - name: Delete a Grafana organization community.grafana.grafana_organization: @@ -36,13 +35,13 @@ name: orgtest state: absent register: result -- assert: +- ansible.builtin.assert: that: - - "result.changed == true" - - "result.failed == false" - - "result.msg |length > 0" + - result.changed == true + - result.failed == false + - result.msg |length > 0 -- name: check idempotency delete a Grafana organization +- name: Check idempotency delete a Grafana organization community.grafana.grafana_organization: url: "{{ grafana_url }}" url_username: "{{ grafana_username }}" @@ -50,8 +49,8 @@ name: orgtest state: absent register: result -- assert: +- ansible.builtin.assert: that: - - "result.changed == false" - - "result.failed == false" - - "result.msg == 'No org found, nothing to do'" + - result.changed == false + - result.failed == false + - result.msg == 'No org found, nothing to do' diff --git a/tests/integration/targets/grafana_organization_user/defaults/main.yml b/tests/integration/targets/grafana_organization_user/defaults/main.yml index 7bb77ea3..3edac859 100644 --- a/tests/integration/targets/grafana_organization_user/defaults/main.yml +++ b/tests/integration/targets/grafana_organization_user/defaults/main.yml @@ -1,4 +1,4 @@ --- -grafana_url: "http://grafana:3000/" -grafana_username: "admin" -grafana_password: "admin" +grafana_url: http://grafana:3000/ +grafana_username: admin +grafana_password: admin diff --git a/tests/integration/targets/grafana_organization_user/tasks/main.yml b/tests/integration/targets/grafana_organization_user/tasks/main.yml index 3ede4f7c..5bfbea6d 100644 --- a/tests/integration/targets/grafana_organization_user/tasks/main.yml +++ b/tests/integration/targets/grafana_organization_user/tasks/main.yml @@ -19,10 +19,10 @@ login: orgtest state: absent register: result -- assert: +- ansible.builtin.assert: that: - - "result.failed == false" - - "result.changed == true" + - result.failed == false + - result.changed == true - name: Check idempotency on user removal from org community.grafana.grafana_organization_user: @@ -32,10 +32,10 @@ login: orgtest state: absent register: result -- assert: +- ansible.builtin.assert: that: - - "result.failed == false" - - "result.changed == false" + - result.failed == false + - result.changed == false - name: Add user to organization community.grafana.grafana_organization_user: @@ -46,12 +46,12 @@ role: viewer state: present register: result -- assert: +- ansible.builtin.assert: that: - - "result.failed == false" - - "result.changed == true" - - "result.user.orgId == 1" - - "result.user.role == 'Viewer'" + - result.failed == false + - result.changed == true + - result.user.orgId == 1 + - result.user.role == 'Viewer' - name: Update existing user role community.grafana.grafana_organization_user: @@ -62,12 +62,12 @@ role: editor state: present register: result -- assert: +- ansible.builtin.assert: that: - - "result.failed == false" - - "result.changed == true" - - "result.user.orgId == 1" - - "result.user.role == 'Editor'" + - result.failed == false + - result.changed == true + - result.user.orgId == 1 + - result.user.role == 'Editor' - name: Check idempotency on user update community.grafana.grafana_organization_user: @@ -78,10 +78,10 @@ role: editor state: present register: result -- assert: +- ansible.builtin.assert: that: - - "result.failed == false" - - "result.changed == false" + - result.failed == false + - result.changed == false - name: Create a new organization community.grafana.grafana_organization: @@ -102,12 +102,12 @@ role: admin state: present register: result -- assert: +- ansible.builtin.assert: that: - - "result.failed == false" - - "result.changed == true" - - "result.user.orgId == org.org.id" - - "result.user.role == 'Admin'" + - result.failed == false + - result.changed == true + - result.user.orgId == org.org.id + - result.user.role == 'Admin' - name: Remove user from new organization by org_id community.grafana.grafana_organization_user: @@ -118,10 +118,10 @@ login: orgtest state: absent register: result -- assert: +- ansible.builtin.assert: that: - - "result.failed == false" - - "result.changed == true" + - result.failed == false + - result.changed == true - name: Add user to the new organization by org_name community.grafana.grafana_organization_user: @@ -133,12 +133,12 @@ role: admin state: present register: result -- assert: +- ansible.builtin.assert: that: - - "result.failed == false" - - "result.changed == true" - - "result.user.orgId == org.org.id" - - "result.user.role == 'Admin'" + - result.failed == false + - result.changed == true + - result.user.orgId == org.org.id + - result.user.role == 'Admin' - name: Remove user from new organization by org_name community.grafana.grafana_organization_user: @@ -149,7 +149,7 @@ login: orgtest state: absent register: result -- assert: +- ansible.builtin.assert: that: - - "result.failed == false" - - "result.changed == true" + - result.failed == false + - result.changed == true diff --git a/tests/integration/targets/grafana_team/defaults/main.yml b/tests/integration/targets/grafana_team/defaults/main.yml index 8b9c9348..4abf9bb4 100644 --- a/tests/integration/targets/grafana_team/defaults/main.yml +++ b/tests/integration/targets/grafana_team/defaults/main.yml @@ -1,7 +1,5 @@ --- -grafana_url: "http://grafana:3000/" -grafana_username: "admin" -grafana_password: "admin" - -... +grafana_url: http://grafana:3000/ +grafana_username: admin +grafana_password: admin diff --git a/tests/integration/targets/grafana_team/tasks/create_user.yml b/tests/integration/targets/grafana_team/tasks/create_user.yml index 6971d07b..9641e718 100644 --- a/tests/integration/targets/grafana_team/tasks/create_user.yml +++ b/tests/integration/targets/grafana_team/tasks/create_user.yml @@ -1,29 +1,30 @@ +--- - name: Create John Doe for tests purpose through uri module - uri: + ansible.builtin.uri: url: "{{ grafana_url }}api/admin/users" method: POST user: "{{ grafana_username }}" password: "{{ grafana_password }}" - force_basic_auth: yes + force_basic_auth: true body: - name: "John" - email: "john+doe@example.com" - login: "john" - password: "userpassword" + name: John + email: john+doe@example.com + login: john + password: userpassword body_format: json status_code: 200 - name: Create Jane Doe for tests purpose through uri module - uri: + ansible.builtin.uri: url: "{{ grafana_url }}api/admin/users" method: POST user: "{{ grafana_username }}" password: "{{ grafana_password }}" - force_basic_auth: yes + force_basic_auth: true body: - name: "Jane" - email: "jane.doe@example.com" - login: "jane" - password: "userpassword" + name: Jane + email: jane.doe@example.com + login: jane + password: userpassword body_format: json status_code: 200 diff --git a/tests/integration/targets/grafana_team/tasks/main.yml b/tests/integration/targets/grafana_team/tasks/main.yml index 2d74581b..24dcd072 100644 --- a/tests/integration/targets/grafana_team/tasks/main.yml +++ b/tests/integration/targets/grafana_team/tasks/main.yml @@ -1,187 +1,187 @@ --- - - name: Create a Team grafana_team: - url: "{{ grafana_url }}" - url_username: "{{ grafana_username }}" - url_password: "{{ grafana_password }}" - name: "grafana_working_group" - email: "foo.bar@example.com" - state: present + url: "{{ grafana_url }}" + url_username: "{{ grafana_username }}" + url_password: "{{ grafana_password }}" + name: grafana_working_group + email: foo.bar@example.com + state: present register: result -- set_fact: +- ansible.builtin.set_fact: # From Grafana 9.0.0, the API user automatically becomes a member of the team auto_member: "{{ result.team.memberCount == 1 }}" -- set_fact: +- ansible.builtin.set_fact: expected_members: "{{ auto_member | ternary(['********@localhost'], []) }}" -- assert: +- ansible.builtin.assert: that: - - "result.changed == true" - - "result.team.name == 'grafana_working_group'" - - "result.team.email == 'foo.bar@example.com'" - - "result.team.memberCount == (expected_members|length)" - - "result.team.members == expected_members" + - result.changed == true + - result.team.name == 'grafana_working_group' + - result.team.email == 'foo.bar@example.com' + - result.team.memberCount == (expected_members|length) + - result.team.members == expected_members - name: Check idempotency on team creation grafana_team: - url: "{{ grafana_url }}" - url_username: "{{ grafana_username }}" - url_password: "{{ grafana_password }}" - name: "grafana_working_group" - email: "foo.bar@example.com" - state: present + url: "{{ grafana_url }}" + url_username: "{{ grafana_username }}" + url_password: "{{ grafana_password }}" + name: grafana_working_group + email: foo.bar@example.com + state: present register: result -- assert: +- ansible.builtin.assert: that: - - "result.changed == false" - - "result.team.name == 'grafana_working_group'" - - "result.team.email == 'foo.bar@example.com'" - - "result.team.memberCount == (expected_members|length)" - - "result.team.members == expected_members" + - result.changed == false + - result.team.name == 'grafana_working_group' + - result.team.email == 'foo.bar@example.com' + - result.team.memberCount == (expected_members|length) + - result.team.members == expected_members - name: Check a team can be deleted grafana_team: - url: "{{ grafana_url }}" - url_username: "{{ grafana_username }}" - url_password: "{{ grafana_password }}" - name: "grafana_working_group" - email: "foo.bar@example.com" - state: absent + url: "{{ grafana_url }}" + url_username: "{{ grafana_username }}" + url_password: "{{ grafana_password }}" + name: grafana_working_group + email: foo.bar@example.com + state: absent register: result -- assert: +- ansible.builtin.assert: that: - - "result.changed == true" - - "result.message == 'Team deleted'" + - result.changed == true + - result.message == 'Team deleted' - name: Check idempotency on team deletion grafana_team: - url: "{{ grafana_url }}" - url_username: "{{ grafana_username }}" - url_password: "{{ grafana_password }}" - name: "grafana_working_group" - email: "foo.bar@example.com" - state: absent + url: "{{ grafana_url }}" + url_username: "{{ grafana_username }}" + url_password: "{{ grafana_password }}" + name: grafana_working_group + email: foo.bar@example.com + state: absent register: result -- assert: +- ansible.builtin.assert: that: - - "result.changed == false" - - "result.message == 'No team found'" + - result.changed == false + - result.message == 'No team found' - name: Create users for tests purpose - import_tasks: create_user.yml - + ansible.builtin.import_tasks: create_user.yml - name: Create a Team with members grafana_team: - url: "{{ grafana_url }}" - url_username: "{{ grafana_username }}" - url_password: "{{ grafana_password }}" - name: "grafana_working_group" - email: "foo.bar@example.com" - members: - - "john+doe@example.com" - - "jane.doe@example.com" - state: present + url: "{{ grafana_url }}" + url_username: "{{ grafana_username }}" + url_password: "{{ grafana_password }}" + name: grafana_working_group + email: foo.bar@example.com + members: + - john+doe@example.com + - jane.doe@example.com + state: present register: result -- set_fact: - expected_members: "{{ auto_member | ternary(['********@localhost', 'jane.doe@example.com', 'john+doe@example.com'], ['jane.doe@example.com', 'john+doe@example.com']) }}" +- ansible.builtin.set_fact: + expected_members: "{{ auto_member | ternary(['********@localhost', 'jane.doe@example.com', 'john+doe@example.com'], ['jane.doe@example.com', 'john+doe@example.com'])\ + \ }}" -- assert: +- ansible.builtin.assert: that: - - "result.changed == true" - - "result.team.name == 'grafana_working_group'" - - "result.team.email == 'foo.bar@example.com'" - - "result.team.memberCount == (expected_members|length)" - - "result.team.members == expected_members" + - result.changed == true + - result.team.name == 'grafana_working_group' + - result.team.email == 'foo.bar@example.com' + - result.team.memberCount == (expected_members|length) + - result.team.members == expected_members - name: Ensure a Team exists with member not enforced grafana_team: - url: "{{ grafana_url }}" - url_username: "{{ grafana_username }}" - url_password: "{{ grafana_password }}" - name: "grafana_working_group" - email: "foo.bar@example.com" - members: - - "john+doe@example.com" - state: present + url: "{{ grafana_url }}" + url_username: "{{ grafana_username }}" + url_password: "{{ grafana_password }}" + name: grafana_working_group + email: foo.bar@example.com + members: + - john+doe@example.com + state: present register: result -- assert: +- ansible.builtin.assert: that: - - "result.changed == false" - - "result.team.name == 'grafana_working_group'" - - "result.team.email == 'foo.bar@example.com'" - - "result.team.memberCount == (expected_members|length)" - - "result.team.members == expected_members" + - result.changed == false + - result.team.name == 'grafana_working_group' + - result.team.email == 'foo.bar@example.com' + - result.team.memberCount == (expected_members|length) + - result.team.members == expected_members -- set_fact: +- ansible.builtin.set_fact: enforced_members: "{{ auto_member | ternary(['admin@localhost', 'john+doe@example.com'], ['john+doe@example.com']) }}" expected_members: "{{ auto_member | ternary(['********@localhost', 'john+doe@example.com'], ['john+doe@example.com']) }}" - name: Ensure a Team exists with member enforced grafana_team: - url: "{{ grafana_url }}" - url_username: "{{ grafana_username }}" - url_password: "{{ grafana_password }}" - name: "grafana_working_group" - email: "foo.bar@example.com" - members: "{{ enforced_members }}" - enforce_members: true - state: present + url: "{{ grafana_url }}" + url_username: "{{ grafana_username }}" + url_password: "{{ grafana_password }}" + name: grafana_working_group + email: foo.bar@example.com + members: "{{ enforced_members }}" + enforce_members: true + state: present register: result -- assert: +- ansible.builtin.assert: that: - - "result.changed == true" - - "result.team.name == 'grafana_working_group'" - - "result.team.email == 'foo.bar@example.com'" - - "result.team.memberCount == (expected_members|length)" - - "result.team.members == expected_members" + - result.changed == true + - result.team.name == 'grafana_working_group' + - result.team.email == 'foo.bar@example.com' + - result.team.memberCount == (expected_members|length) + - result.team.members == expected_members - name: Ensure a Team exists with members omitted grafana_team: - url: "{{ grafana_url }}" - url_username: "{{ grafana_username }}" - url_password: "{{ grafana_password }}" - name: "grafana_working_group" - email: "foo.bar@example.com" - state: present + url: "{{ grafana_url }}" + url_username: "{{ grafana_username }}" + url_password: "{{ grafana_password }}" + name: grafana_working_group + email: foo.bar@example.com + state: present register: result -- assert: +- ansible.builtin.assert: that: - - "result.changed == false" - - "result.team.name == 'grafana_working_group'" - - "result.team.email == 'foo.bar@example.com'" - - "result.team.memberCount == (expected_members|length)" - - "result.team.members == expected_members" + - result.changed == false + - result.team.name == 'grafana_working_group' + - result.team.email == 'foo.bar@example.com' + - result.team.memberCount == (expected_members|length) + - result.team.members == expected_members - name: Add new member to existing Team grafana_team: - url: "{{ grafana_url }}" - url_username: "{{ grafana_username }}" - url_password: "{{ grafana_password }}" - name: "grafana_working_group" - email: "foo.bar@example.com" - members: - - "john+doe@example.com" - - "jane.doe@example.com" - state: present + url: "{{ grafana_url }}" + url_username: "{{ grafana_username }}" + url_password: "{{ grafana_password }}" + name: grafana_working_group + email: foo.bar@example.com + members: + - john+doe@example.com + - jane.doe@example.com + state: present register: result -- set_fact: - expected_members: "{{ auto_member | ternary(['********@localhost', 'jane.doe@example.com', 'john+doe@example.com'], ['jane.doe@example.com', 'john+doe@example.com']) }}" +- ansible.builtin.set_fact: + expected_members: "{{ auto_member | ternary(['********@localhost', 'jane.doe@example.com', 'john+doe@example.com'], ['jane.doe@example.com', 'john+doe@example.com'])\ + \ }}" -- assert: +- ansible.builtin.assert: that: - - "result.changed == true" - - "result.team.name == 'grafana_working_group'" - - "result.team.email == 'foo.bar@example.com'" - - "result.team.memberCount == (expected_members|length)" - - "result.team.members == expected_members" + - result.changed == true + - result.team.name == 'grafana_working_group' + - result.team.email == 'foo.bar@example.com' + - result.team.memberCount == (expected_members|length) + - result.team.members == expected_members diff --git a/tests/integration/targets/grafana_user/defaults/main.yml b/tests/integration/targets/grafana_user/defaults/main.yml index 7bb77ea3..3edac859 100644 --- a/tests/integration/targets/grafana_user/defaults/main.yml +++ b/tests/integration/targets/grafana_user/defaults/main.yml @@ -1,4 +1,4 @@ --- -grafana_url: "http://grafana:3000/" -grafana_username: "admin" -grafana_password: "admin" +grafana_url: http://grafana:3000/ +grafana_username: admin +grafana_password: admin diff --git a/tests/integration/targets/grafana_user/tasks/main.yml b/tests/integration/targets/grafana_user/tasks/main.yml index c6280165..cf04bc87 100644 --- a/tests/integration/targets/grafana_user/tasks/main.yml +++ b/tests/integration/targets/grafana_user/tasks/main.yml @@ -4,72 +4,72 @@ url: "{{ grafana_url }}" url_username: "{{ grafana_username }}" url_password: "{{ grafana_password }}" - name: "Harley Quinn" + name: Harley Quinn email: harley.quinn@gotham.city login: harley password: Wy3ta6ob6M3wHELv58MPfqOe126RTnWpcYfEhyJm is_admin: true state: present register: result -- assert: +- ansible.builtin.assert: that: - - "result.changed == true" - - "result.failed == false" - - "result.user.name == 'Harley Quinn'" - - "result.user.email == 'harley.quinn@gotham.city'" - - "result.user.isGrafanaAdmin == true" + - result.changed == true + - result.failed == false + - result.user.name == 'Harley Quinn' + - result.user.email == 'harley.quinn@gotham.city' + - result.user.isGrafanaAdmin == true - name: Check idempotency on admin creation grafana_user: url: "{{ grafana_url }}" url_username: "{{ grafana_username }}" url_password: "{{ grafana_password }}" - name: "Harley Quinn" + name: Harley Quinn email: harley.quinn@gotham.city login: harley password: Wy3ta6ob6M3wHELv58MPfqOe126RTnWpcYfEhyJm is_admin: true state: present register: result -- assert: +- ansible.builtin.assert: that: - - "result.changed == false" - - "result.user.name == 'Harley Quinn'" - - "result.user.email == 'harley.quinn@gotham.city'" - - "result.user.isGrafanaAdmin == true" + - result.changed == false + - result.user.name == 'Harley Quinn' + - result.user.email == 'harley.quinn@gotham.city' + - result.user.isGrafanaAdmin == true - name: Check user creation with Grafana API - uri: + ansible.builtin.uri: url: "{{ grafana_url }}api/users/lookup?loginOrEmail=harley" user: "{{ grafana_username }}" password: "{{ grafana_password }}" - force_basic_auth: yes + force_basic_auth: true status_code: 200 headers: Accept: application/json Content-Type: application/json register: result -- assert: +- ansible.builtin.assert: that: - - "result.json.name == 'Harley Quinn'" - - "result.json.email == 'harley.quinn@gotham.city'" - - "result.json.isGrafanaAdmin == true" + - result.json.name == 'Harley Quinn' + - result.json.email == 'harley.quinn@gotham.city' + - result.json.isGrafanaAdmin == true - name: Create a Grafana user without password (expect failure) grafana_user: url: "{{ grafana_url }}" url_username: "{{ grafana_username }}" url_password: "{{ grafana_password }}" - name: "Bruce Wayne" + name: Bruce Wayne email: batman@gotham.city login: batman state: present register: result - ignore_errors: yes -- assert: + ignore_errors: true +- ansible.builtin.assert: that: - - "result.changed == false" - - "result.failed == true" + - result.changed == false + - result.failed == true - "result.msg == 'missing required arguments: password'" - name: Create a Grafana user @@ -77,88 +77,88 @@ url: "{{ grafana_url }}" url_username: "{{ grafana_username }}" url_password: "{{ grafana_password }}" - name: "Bruce Wayne" + name: Bruce Wayne email: batman@gotham.city login: batman password: robin state: present register: result -- assert: +- ansible.builtin.assert: that: - - "result.changed == true" - - "result.user.name == 'Bruce Wayne'" - - "result.user.email == 'batman@gotham.city'" - - "result.user.isGrafanaAdmin == false" + - result.changed == true + - result.user.name == 'Bruce Wayne' + - result.user.email == 'batman@gotham.city' + - result.user.isGrafanaAdmin == false - name: Check idempotency on user creation (password not requiered) grafana_user: url: "{{ grafana_url }}" url_username: "{{ grafana_username }}" url_password: "{{ grafana_password }}" - name: "Bruce Wayne" + name: Bruce Wayne email: batman@gotham.city login: batman state: present register: result -- assert: +- ansible.builtin.assert: that: - - "result.changed == false" - - "result.user.name == 'Bruce Wayne'" - - "result.user.email == 'batman@gotham.city'" - - "result.user.isGrafanaAdmin == false" + - result.changed == false + - result.user.name == 'Bruce Wayne' + - result.user.email == 'batman@gotham.city' + - result.user.isGrafanaAdmin == false - name: Check user creation with Grafana API - uri: + ansible.builtin.uri: url: "{{ grafana_url }}api/users/lookup?loginOrEmail=batman" user: "{{ grafana_username }}" password: "{{ grafana_password }}" - force_basic_auth: yes + force_basic_auth: true status_code: 200 headers: Accept: application/json Content-Type: application/json register: result -- assert: +- ansible.builtin.assert: that: - - "result.json.name == 'Bruce Wayne'" - - "result.json.email == 'batman@gotham.city'" - - "result.json.isGrafanaAdmin == false" + - result.json.name == 'Bruce Wayne' + - result.json.email == 'batman@gotham.city' + - result.json.isGrafanaAdmin == false - name: Update Grafana user grafana_user: url: "{{ grafana_url }}" url_username: "{{ grafana_username }}" url_password: "{{ grafana_password }}" - name: "The Dark Knight" + name: The Dark Knight email: thedarkknight@gotham.city login: batman password: robin is_admin: true state: present register: result -- assert: +- ansible.builtin.assert: that: - - "result.changed == true" - - "result.user.name == 'The Dark Knight'" - - "result.user.email == 'thedarkknight@gotham.city'" - - "result.user.isGrafanaAdmin == true" + - result.changed == true + - result.user.name == 'The Dark Knight' + - result.user.email == 'thedarkknight@gotham.city' + - result.user.isGrafanaAdmin == true - name: Check user update with Grafana API - uri: + ansible.builtin.uri: url: "{{ grafana_url }}api/users/lookup?loginOrEmail=batman" user: "{{ grafana_username }}" password: "{{ grafana_password }}" - force_basic_auth: yes + force_basic_auth: true status_code: 200 headers: Accept: application/json Content-Type: application/json register: result -- assert: +- ansible.builtin.assert: that: - - "result.json.name == 'The Dark Knight'" - - "result.json.email == 'thedarkknight@gotham.city'" - - "result.json.isGrafanaAdmin == true" + - result.json.name == 'The Dark Knight' + - result.json.email == 'thedarkknight@gotham.city' + - result.json.isGrafanaAdmin == true - name: Delete a Grafana user grafana_user: @@ -168,10 +168,10 @@ login: batman state: absent register: result -- assert: +- ansible.builtin.assert: that: - - "result.changed == true" - - "result.message == 'User deleted'" + - result.changed == true + - result.message == 'User deleted' - name: Check idempotency on user deletion grafana_user: @@ -181,57 +181,57 @@ login: batman state: absent register: result -- assert: +- ansible.builtin.assert: that: - - "result.changed == false" - - "result.message == 'No user found, nothing to do'" + - result.changed == false + - result.message == 'No user found, nothing to do' - name: Check user deletion with Grafana API (expect 404 Not Found) - uri: + ansible.builtin.uri: url: "{{ grafana_url }}api/users/lookup?loginOrEmail=batman" user: "{{ grafana_username }}" password: "{{ grafana_password }}" - force_basic_auth: yes + force_basic_auth: true status_code: 404 headers: Accept: application/json Content-Type: application/json register: result -- assert: +- ansible.builtin.assert: that: - - "result.json.message | lower == 'user not found'" + - result.json.message | lower == 'user not found' - name: Create a Grafana user with character encoding grafana_user: url: "{{ grafana_url }}" url_username: "{{ grafana_username }}" url_password: "{{ grafana_password }}" - name: "Bruce Wayne" + name: Bruce Wayne email: bruce+wayne@gotham.city login: bruce+wayne@gotham.city password: robin state: present register: result -- assert: +- ansible.builtin.assert: that: - - "result.changed == true" - - "result.user.name == 'Bruce Wayne'" - - "result.user.email == 'bruce+wayne@gotham.city'" - - "result.user.isGrafanaAdmin == false" + - result.changed == true + - result.user.name == 'Bruce Wayne' + - result.user.email == 'bruce+wayne@gotham.city' + - result.user.isGrafanaAdmin == false - name: Check idempotency on user creation (password not requiered) grafana_user: url: "{{ grafana_url }}" url_username: "{{ grafana_username }}" url_password: "{{ grafana_password }}" - name: "Bruce Wayne" + name: Bruce Wayne email: bruce+wayne@gotham.city login: bruce+wayne@gotham.city state: present register: result -- assert: +- ansible.builtin.assert: that: - - "result.changed == false" - - "result.user.name == 'Bruce Wayne'" - - "result.user.email == 'bruce+wayne@gotham.city'" - - "result.user.isGrafanaAdmin == false" + - result.changed == false + - result.user.name == 'Bruce Wayne' + - result.user.email == 'bruce+wayne@gotham.city' + - result.user.isGrafanaAdmin == false