Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix consistency issue in grafana_dashboard module. #47459

Merged
merged 3 commits into from
Nov 9, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
bugfixes:
- Fix consistency issue in grafana_dashboard module where the module would detect absence of 'dashboard' key on dashboard create but not dashboard update.
6 changes: 4 additions & 2 deletions lib/ansible/modules/monitoring/grafana_dashboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,10 @@ def grafana_create_dashboard(module, data):
except Exception as e:
raise GrafanaAPIException("Can't load json file %s" % to_native(e))

# Check that the dashboard JSON is nested under the 'dashboard' key
if 'dashboard' not in payload:
payload = {'dashboard': payload}

# define http header
headers = grafana_headers(module, data)

Expand Down Expand Up @@ -278,8 +282,6 @@ def grafana_create_dashboard(module, data):
raise GrafanaAPIException('Unable to update the dashboard %s : %s' % (uid, body['message']))
else:
# create
if 'dashboard' not in payload:
payload = {'dashboard': payload}
r, info = fetch_url(module, '%s/api/dashboards/db' % data['grafana_url'], data=json.dumps(payload), headers=headers, method='POST')
if info['status'] == 200:
result['msg'] = "Dashboard %s created" % uid
Expand Down