forked from CCCHH/ansible-infra
Vendor Galaxy Roles and Collections
This commit is contained in:
parent
c1e1897cda
commit
2aed20393f
3553 changed files with 387444 additions and 2 deletions
|
|
@ -0,0 +1 @@
|
|||
requests
|
||||
|
|
@ -0,0 +1,80 @@
|
|||
---
|
||||
- name: Create Alerting contact point
|
||||
grafana.grafana.alert_contact_point:
|
||||
name: ops-email
|
||||
uid: opsemail
|
||||
type: email
|
||||
settings:
|
||||
addresses: ops@mydomain.com,devs@mydomain.com
|
||||
grafana_ini:
|
||||
server:
|
||||
root_url: "{{ grafana_url }}"
|
||||
grafana_api_key: "{{ grafana_api_key }}"
|
||||
state: present
|
||||
register: add_result
|
||||
|
||||
- name: Add Check
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- add_result.failed == false
|
||||
- add_result.output.provenance == "api"
|
||||
|
||||
- name: Idempotency Check
|
||||
grafana.grafana.alert_contact_point:
|
||||
name: ops-email
|
||||
uid: opsemail
|
||||
type: email
|
||||
settings:
|
||||
addresses: ops@mydomain.com,devs@mydomain.com
|
||||
grafana_ini:
|
||||
server:
|
||||
root_url: "{{ grafana_url }}"
|
||||
grafana_api_key: "{{ grafana_api_key }}"
|
||||
state: present
|
||||
register: idempotent_result
|
||||
|
||||
- name: Changed Check
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- idempotent_result.changed == false
|
||||
- idempotent_result.output.provenance == "api"
|
||||
|
||||
- name: Update Alerting contact point
|
||||
grafana.grafana.alert_contact_point:
|
||||
name: ops-email
|
||||
uid: opsemail
|
||||
type: email
|
||||
settings:
|
||||
addresses: "ops@mydomain.com,devs@mydomain.com,admin@mydomain.com"
|
||||
grafana_ini:
|
||||
server:
|
||||
root_url: "{{ grafana_url }}"
|
||||
grafana_api_key: "{{ grafana_api_key }}"
|
||||
state: present
|
||||
register: update_result
|
||||
|
||||
- name: Failed Check
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- update_result.failed == false
|
||||
- update_result.output.provenance == "api"
|
||||
|
||||
- name: Delete Alerting contact point
|
||||
grafana.grafana.alert_contact_point:
|
||||
name: ops-email
|
||||
uid: opsemail
|
||||
type: email
|
||||
settings:
|
||||
addresses: "ops@mydomain.com,devs@mydomain.com,admin@mydomain.com"
|
||||
grafana_ini:
|
||||
server:
|
||||
root_url: "{{ grafana_url }}"
|
||||
grafana_api_key: "{{ grafana_api_key }}"
|
||||
state: absent
|
||||
register: delete_result
|
||||
|
||||
- name: Delete Check
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- delete_result.failed == false
|
||||
- delete_result.output.message == "contactpoint deleted"
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
- name: Set Notification policy tree
|
||||
grafana.grafana.alert_notification_policy:
|
||||
grafana_ini:
|
||||
server:
|
||||
root_url: "{{ grafana_url }}"
|
||||
grafana_api_key: "{{ grafana_api_key }}"
|
||||
routes: [
|
||||
{
|
||||
receiver: grafana-default-email,
|
||||
object_matchers: [["env", "=", "Production"]],
|
||||
}
|
||||
]
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- result.failed == false
|
||||
|
|
@ -0,0 +1,45 @@
|
|||
---
|
||||
- name: Create Grafana Cloud API key
|
||||
grafana.grafana.cloud_api_key:
|
||||
name: ansible-integration-test
|
||||
role: Admin
|
||||
org_slug: "{{ org_name }}"
|
||||
existing_cloud_api_key: "{{ grafana_cloud_api_key }}"
|
||||
fail_if_already_created: false
|
||||
state: present
|
||||
register: add_result
|
||||
|
||||
- name: Add Check
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- add_result.output.name == "ansible-integration-test"
|
||||
when: add_result.output.name is defined
|
||||
|
||||
- name: Re-run previous task
|
||||
grafana.grafana.cloud_api_key:
|
||||
name: ansible-integration-test
|
||||
role: Admin
|
||||
org_slug: "{{ org_name }}"
|
||||
existing_cloud_api_key: "{{ grafana_cloud_api_key }}"
|
||||
fail_if_already_created: false
|
||||
state: present
|
||||
register: update_result
|
||||
|
||||
- name: Update Check
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- update_result.output == "A Cloud API key with the same name already exists"
|
||||
|
||||
- name: Delete Grafana Cloud API key
|
||||
grafana.grafana.cloud_api_key:
|
||||
name: ansible-integration-test
|
||||
role: Admin
|
||||
org_slug: "{{ org_name }}"
|
||||
existing_cloud_api_key: "{{ grafana_cloud_api_key }}"
|
||||
state: absent
|
||||
register: delete_result
|
||||
|
||||
- name: Delete Check
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- delete_result.output == "Cloud API key is deleted"
|
||||
|
|
@ -0,0 +1,56 @@
|
|||
---
|
||||
- name: Add a plugin
|
||||
grafana.grafana.cloud_plugin:
|
||||
name: grafana-github-datasource
|
||||
version: 1.0.14
|
||||
stack_slug: "{{ test_stack_name }}"
|
||||
cloud_api_key: "{{ grafana_cloud_api_key }}"
|
||||
state: present
|
||||
register: add_result
|
||||
|
||||
- name: Add Check
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- add_result.pluginName == "GitHub"
|
||||
|
||||
- name: Idempotency Check
|
||||
grafana.grafana.cloud_plugin:
|
||||
name: grafana-github-datasource
|
||||
version: 1.0.14
|
||||
stack_slug: "{{ test_stack_name }}"
|
||||
cloud_api_key: "{{ grafana_cloud_api_key }}"
|
||||
state: present
|
||||
register: idempotency_result
|
||||
|
||||
- name: Idempotency Check
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- idempotency_result.pluginName == "GitHub"
|
||||
|
||||
- name: Update a plugin
|
||||
grafana.grafana.cloud_plugin:
|
||||
name: grafana-github-datasource
|
||||
version: 1.0.15
|
||||
stack_slug: "{{ test_stack_name }}"
|
||||
cloud_api_key: "{{ grafana_cloud_api_key }}"
|
||||
state: present
|
||||
register: update_result
|
||||
|
||||
- name: Update Check
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- update_result.pluginName == "GitHub"
|
||||
|
||||
- name: Delete a plugin
|
||||
grafana.grafana.cloud_plugin:
|
||||
name: grafana-github-datasource
|
||||
version: 1.0.15
|
||||
stack_slug: "{{ test_stack_name }}"
|
||||
cloud_api_key: "{{ grafana_cloud_api_key }}"
|
||||
state: absent
|
||||
register: delete_result
|
||||
|
||||
- name: Delete Check
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- delete_result.pluginName == "GitHub"
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
---
|
||||
- name: Create a Grafana Cloud stack
|
||||
grafana.grafana.cloud_stack:
|
||||
name: "{{ test_stack_name }}"
|
||||
stack_slug: "{{ test_stack_name }}"
|
||||
cloud_api_key: "{{ grafana_cloud_api_key }}"
|
||||
org_slug: "{{ org_name }}"
|
||||
state: present
|
||||
register: create_result
|
||||
|
||||
- name: Create Check
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- create_result.url == "https://" + "{{ test_stack_name }}" + ".grafana.net"
|
||||
|
||||
- name: Sleep for 45 seconds
|
||||
ansible.builtin.wait_for:
|
||||
timeout: 45
|
||||
|
|
@ -0,0 +1,52 @@
|
|||
---
|
||||
- name: Create/Update a dashboard
|
||||
grafana.grafana.dashboard:
|
||||
dashboard:
|
||||
dashboard:
|
||||
uid: test1234
|
||||
title: Ansible Integration Test
|
||||
tags:
|
||||
- templated
|
||||
timezone: browser
|
||||
schemaVersion: 16
|
||||
refresh: 25s
|
||||
version: 0
|
||||
overwrite: true
|
||||
grafana_ini:
|
||||
server:
|
||||
root_url: "{{ grafana_url }}"
|
||||
grafana_api_key: "{{ grafana_api_key }}"
|
||||
state: present
|
||||
register: result_present
|
||||
|
||||
- name: Create/Update Check
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- result_present.changed == true
|
||||
- result_present.output.status == "success"
|
||||
|
||||
- name: Delete dashboard
|
||||
grafana.grafana.dashboard:
|
||||
dashboard:
|
||||
dashboard:
|
||||
uid: test1234
|
||||
title: Ansible Integration Test
|
||||
tags:
|
||||
- templated
|
||||
timezone: browser
|
||||
schemaVersion: 16
|
||||
version: 0
|
||||
refresh: 25s
|
||||
overwrite: true
|
||||
grafana_ini:
|
||||
server:
|
||||
root_url: "{{ grafana_url }}"
|
||||
grafana_api_key: "{{ grafana_api_key }}"
|
||||
state: absent
|
||||
register: result_absent
|
||||
|
||||
- name: Delete Check
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- result_absent.changed == true
|
||||
- result_absent.output.message == "Dashboard Ansible Integration Test deleted"
|
||||
|
|
@ -0,0 +1,52 @@
|
|||
---
|
||||
- name: Create/Update a Data Source
|
||||
grafana.grafana.datasource:
|
||||
dataSource:
|
||||
name: ansible-integration
|
||||
type: influxdb
|
||||
url: https://grafana.github.com/grafana-ansible-collection
|
||||
user: user
|
||||
secureJsonData:
|
||||
password: password
|
||||
database: db-name
|
||||
id: 123
|
||||
uid: ansibletest
|
||||
access: proxy
|
||||
grafana_ini:
|
||||
server:
|
||||
root_url: "{{ grafana_url }}"
|
||||
grafana_api_key: "{{ grafana_api_key }}"
|
||||
state: present
|
||||
register: create_result
|
||||
|
||||
- name: Create Check
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- create_result.changed == true
|
||||
- create_result.output.message == "Datasource added" or create_result.output.message == "Datasource updated"
|
||||
|
||||
- name: Delete a Data Source
|
||||
grafana.grafana.datasource:
|
||||
dataSource:
|
||||
name: ansible-integration
|
||||
type: influxdb
|
||||
url: https://grafana.github.com/grafana-ansible-collection
|
||||
user: user
|
||||
secureJsonData:
|
||||
password: password
|
||||
database: db-name
|
||||
id: 123
|
||||
uid: ansibletest
|
||||
access: proxy
|
||||
grafana_ini:
|
||||
server:
|
||||
root_url: "{{ grafana_url }}"
|
||||
grafana_api_key: "{{ grafana_api_key }}"
|
||||
state: absent
|
||||
register: delete_result
|
||||
|
||||
- name: Delete Check
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- delete_result.changed == true
|
||||
- delete_result.output.response == "Data source deleted"
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
---
|
||||
- name: Delete a Grafana Cloud stack
|
||||
grafana.grafana.cloud_stack:
|
||||
name: "{{ test_stack_name }}"
|
||||
stack_slug: "{{ test_stack_name }}"
|
||||
cloud_api_key: "{{ grafana_cloud_api_key }}"
|
||||
org_slug: "{{ org_name }}"
|
||||
state: absent
|
||||
register: delete_result
|
||||
|
||||
- name: Delete Check
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- delete_result.changed == true
|
||||
- delete_result.url == "https://" + "{{ test_stack_name }}" + ".grafana.net"
|
||||
|
||||
- name: Sleep for 45 seconds
|
||||
ansible.builtin.wait_for:
|
||||
timeout: 45
|
||||
|
|
@ -0,0 +1,53 @@
|
|||
---
|
||||
- name: Create/Update a Folder in Grafana
|
||||
grafana.grafana.folder:
|
||||
title: Ansible Integration test
|
||||
uid: test123
|
||||
overwrite: true
|
||||
grafana_ini:
|
||||
server:
|
||||
root_url: "{{ grafana_url }}"
|
||||
grafana_api_key: "{{ grafana_api_key }}"
|
||||
state: present
|
||||
register: create_result
|
||||
|
||||
- name: Create Check
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- create_result.failed == false
|
||||
|
||||
- name: Delete a folder
|
||||
grafana.grafana.folder:
|
||||
title: Ansible Integration test
|
||||
uid: test123
|
||||
overwrite: true
|
||||
grafana_ini:
|
||||
server:
|
||||
root_url: "{{ grafana_url }}"
|
||||
grafana_api_key: "{{ grafana_api_key }}"
|
||||
state: absent
|
||||
register: delete_result
|
||||
|
||||
- name: Delete Check
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- delete_result.output.status == 200
|
||||
- delete_result.output.response == "Folder has been succesfuly deleted"
|
||||
|
||||
- name: Delete Idempotency Check
|
||||
grafana.grafana.folder:
|
||||
title: Ansible Integration test
|
||||
uid: test123
|
||||
overwrite: true
|
||||
grafana_ini:
|
||||
server:
|
||||
root_url: "{{ grafana_url }}"
|
||||
grafana_api_key: "{{ grafana_api_key }}"
|
||||
state: absent
|
||||
register: delete_result
|
||||
|
||||
- name: Delete Check
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- delete_result.output.status == 200
|
||||
- delete_result.output.response == "Folder does not exist"
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
version="0.1.3"
|
||||
src="https://github.com/gardar/ansible-test-molecule/releases/download/$version/ansible-test-molecule.sh"
|
||||
|
||||
# shellcheck disable=SC1090
|
||||
if [[ -v GITHUB_TOKEN ]]
|
||||
then
|
||||
source <(curl -L -s -H "Authorization: token $GITHUB_TOKEN" $src)
|
||||
else
|
||||
source <(curl -L -s $src)
|
||||
fi
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
version="0.1.3"
|
||||
src="https://github.com/gardar/ansible-test-molecule/releases/download/$version/ansible-test-molecule.sh"
|
||||
|
||||
# shellcheck disable=SC1090
|
||||
if [[ -v GITHUB_TOKEN ]]
|
||||
then
|
||||
source <(curl -L -s -H "Authorization: token $GITHUB_TOKEN" $src)
|
||||
else
|
||||
source <(curl -L -s $src)
|
||||
fi
|
||||
|
|
@ -0,0 +1,60 @@
|
|||
---
|
||||
- name: Create an User in Grafana
|
||||
grafana.grafana.user:
|
||||
login: "grafana_user"
|
||||
password: "Yeihohghomi2neipuphuakooWeeph3ox"
|
||||
email: "grafana_user@localhost.local"
|
||||
name: "grafana user"
|
||||
grafana_url: "{{ grafana_url }}"
|
||||
admin_name: "admin"
|
||||
admin_password: "admin"
|
||||
state: present
|
||||
register: create_result
|
||||
|
||||
- name: Create Check
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- create_result.failed == false
|
||||
|
||||
- name: Change an User password in Grafana
|
||||
grafana.grafana.user:
|
||||
login: "grafana_user"
|
||||
password: "Yeihohghomi2neipuphuakooWeeph3ox"
|
||||
grafana_url: "{{ grafana_url }}"
|
||||
admin_name: "admin"
|
||||
admin_password: "admin"
|
||||
state: update_password
|
||||
register: update_result
|
||||
|
||||
- name: Create Check
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- update_result.failed == false
|
||||
|
||||
- name: Delete a user
|
||||
grafana.grafana.user:
|
||||
login: "grafana_user"
|
||||
grafana_url: "{{ grafana_url }}"
|
||||
admin_name: "admin"
|
||||
admin_password: "admin"
|
||||
state: absent
|
||||
register: delete_result
|
||||
|
||||
- name: Delete Check
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- delete_result.failed == false
|
||||
|
||||
- name: Delete Idempotency Check
|
||||
grafana.grafana.user:
|
||||
login: "grafana_user"
|
||||
grafana_url: "{{ grafana_url }}"
|
||||
admin_name: "admin"
|
||||
admin_password: "admin"
|
||||
state: absent
|
||||
register: delete_result
|
||||
|
||||
- name: Delete Check
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- delete_result.failed == false
|
||||
Loading…
Add table
Add a link
Reference in a new issue