Skip to content

Commit

Permalink
Port ansible-collection-migration diff
Browse files Browse the repository at this point in the history
Closes: #66
  • Loading branch information
rrey committed Mar 17, 2020
1 parent 6fbae53 commit b2b6618
Show file tree
Hide file tree
Showing 3 changed files with 101 additions and 112 deletions.
177 changes: 87 additions & 90 deletions plugins/callback/grafana_annotations.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,95 +27,92 @@
from ansible.plugins.callback import CallbackBase


DOCUMENTATION = '''callback: grafana_annotations
callback_type: notification
short_description: send ansible events as annotations on charts to grafana over http
api.
author: Rémi REY (@rrey)
description:
- This callback will report start, failed and stats events to Grafana as annotations
(https://grafana.com)
requirements:
- whitelisting in configuration
options:
grafana_url:
description: Grafana annotations api URL
required: true
env:
- name: GRAFANA_URL
ini:
- section: callback_grafana_annotations
key: grafana_url
type: string
validate_certs:
description: validate the SSL certificate of the Grafana server. (For HTTPS url)
env:
- name: GRAFANA_VALIDATE_CERT
ini:
- section: callback_grafana_annotations
key: validate_grafana_certs
- section: callback_grafana_annotations
key: validate_certs
default: true
type: bool
aliases:
- validate_grafana_certs
http_agent:
description: The HTTP 'User-agent' value to set in HTTP requets.
env:
- name: HTTP_AGENT
ini:
- section: callback_grafana_annotations
key: http_agent
default: Ansible (grafana_annotations callback)
type: string
grafana_api_key:
description: Grafana API key, allowing to authenticate when posting on the HTTP
API. If not provided, grafana_login and grafana_password will be required.
env:
- name: GRAFANA_API_KEY
ini:
- section: callback_grafana_annotations
key: grafana_api_key
type: string
grafana_user:
description: Grafana user used for authentication. Ignored if grafana_api_key
is provided.
env:
- name: GRAFANA_USER
ini:
- section: callback_grafana_annotations
key: grafana_user
default: ansible
type: string
grafana_password:
description: Grafana password used for authentication. Ignored if grafana_api_key
is provided.
env:
- name: GRAFANA_PASSWORD
ini:
- section: callback_grafana_annotations
key: grafana_password
default: ansible
type: string
grafana_dashboard_id:
description: The grafana dashboard id where the annotation shall be created.
env:
- name: GRAFANA_DASHBOARD_ID
ini:
- section: callback_grafana_annotations
key: grafana_dashboard_id
type: integer
grafana_panel_ids:
description: The grafana panel ids where the annotation shall be created. Give
a single integer or a comma-separated list of integers.
env:
- name: GRAFANA_PANEL_IDS
ini:
- section: callback_grafana_annotations
key: grafana_panel_ids
default: []
type: list
DOCUMENTATION = '''
callback: grafana_annotations
callback_type: notification
short_description: send ansible events as annotations on charts to grafana over http api.
author: "Rémi REY (@rrey)"
description:
- This callback will report start, failed and stats events to Grafana as annotations (https://grafana.com)
requirements:
- whitelisting in configuration
options:
grafana_url:
description: Grafana annotations api URL
required: True
env:
- name: GRAFANA_URL
ini:
- section: callback_grafana_annotations
key: grafana_url
type: string
validate_certs:
description: validate the SSL certificate of the Grafana server. (For HTTPS url)
env:
- name: GRAFANA_VALIDATE_CERT
ini:
- section: callback_grafana_annotations
key: validate_grafana_certs
- section: callback_grafana_annotations
key: validate_certs
default: True
type: bool
aliases: [ validate_grafana_certs ]
http_agent:
description: The HTTP 'User-agent' value to set in HTTP requets.
env:
- name: HTTP_AGENT
ini:
- section: callback_grafana_annotations
key: http_agent
default: 'Ansible (grafana_annotations callback)'
type: string
grafana_api_key:
description: Grafana API key, allowing to authenticate when posting on the HTTP API.
If not provided, grafana_login and grafana_password will
be required.
env:
- name: GRAFANA_API_KEY
ini:
- section: callback_grafana_annotations
key: grafana_api_key
type: string
grafana_user:
description: Grafana user used for authentication. Ignored if grafana_api_key is provided.
env:
- name: GRAFANA_USER
ini:
- section: callback_grafana_annotations
key: grafana_user
default: ansible
type: string
grafana_password:
description: Grafana password used for authentication. Ignored if grafana_api_key is provided.
env:
- name: GRAFANA_PASSWORD
ini:
- section: callback_grafana_annotations
key: grafana_password
default: ansible
type: string
grafana_dashboard_id:
description: The grafana dashboard id where the annotation shall be created.
env:
- name: GRAFANA_DASHBOARD_ID
ini:
- section: callback_grafana_annotations
key: grafana_dashboard_id
type: integer
grafana_panel_ids:
description: The grafana panel ids where the annotation shall be created.
Give a single integer or a comma-separated list of integers.
env:
- name: GRAFANA_PANEL_IDS
ini:
- section: callback_grafana_annotations
key: grafana_panel_ids
default: []
type: list
'''


Expand Down Expand Up @@ -165,7 +162,7 @@ class CallbackModule(CallbackBase):

CALLBACK_VERSION = 2.0
CALLBACK_TYPE = 'aggregate'
CALLBACK_NAME = 'ansible_community.grafana.grafana_annotations'
CALLBACK_NAME = 'community.grafana.grafana_annotations'
CALLBACK_NEEDS_WHITELIST = True

def __init__(self, display=None):
Expand Down
29 changes: 14 additions & 15 deletions plugins/lookup/grafana_dashboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,46 +7,45 @@
'status': ['preview'],
'supported_by': 'community'}

DOCUMENTATION = '''lookup: grafana_dashboard
DOCUMENTATION = '''
lookup: grafana_dashboard
author: Thierry Salle (@seuf)
short_description: list or search grafana dashboards
description:
- This lookup returns a list of grafana dashboards with possibility to filter them
by query.
- This lookup returns a list of grafana dashboards with possibility to filter them by query.
options:
grafana_url:
description: url of grafana.
env:
- name: GRAFANA_URL
- name: GRAFANA_URL
default: http://127.0.0.1:3000
grafana_api_key:
description:
- api key of grafana.
- when C(grafana_api_key) is set, the options C(grafan_user), C(grafana_password)
and C(grafana_org_id) are ignored.
- Attention, please remove the two == at the end of the grafana_api_key
- because ansible lookup plugins options are split on = (see example).
- api key of grafana.
- when C(grafana_api_key) is set, the options C(grafan_user), C(grafana_password) and C(grafana_org_id) are ignored.
- Attention, please remove the two == at the end of the grafana_api_key
- because ansible lookup plugins options are split on = (see example).
env:
- name: GRAFANA_API_KEY
- name: GRAFANA_API_KEY
grafana_user:
description: grafana authentication user.
env:
- name: GRAFANA_USER
- name: GRAFANA_USER
default: admin
grafana_password:
description: grafana authentication password.
description: grafana authentication password.
env:
- name: GRAFANA_PASSWORD
- name: GRAFANA_PASSWORD
default: admin
grafana_org_id:
description: grafana organisation id.
env:
- name: GRAFANA_ORG_ID
- name: GRAFANA_ORG_ID
default: 1
search:
description: optional filter for dashboard search.
env:
- name: GRAFANA_DASHBOARD_SEARCH
- name: GRAFANA_DASHBOARD_SEARCH
'''

EXAMPLES = """
Expand Down
7 changes: 0 additions & 7 deletions tests/sanity/ignore-2.9.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1 @@
plugins/modules/grafana_dashboard.py validate-modules:parameter-type-not-in-doc
plugins/modules/grafana_dashboard.py validate-modules:doc-missing-type
plugins/modules/grafana_datasource.py validate-modules:doc-default-does-not-match-spec
plugins/modules/grafana_datasource.py validate-modules:parameter-type-not-in-doc
plugins/modules/grafana_datasource.py validate-modules:doc-missing-type
plugins/modules/grafana_plugin.py validate-modules:parameter-type-not-in-doc
plugins/modules/grafana_plugin.py validate-modules:doc-missing-type
tests/unit/modules/grafana/grafana_plugin/test_grafana_plugin.py pep8:W291

0 comments on commit b2b6618

Please sign in to comment.