Skip to content
This repository was archived by the owner on May 31, 2023. It is now read-only.

Commit c8648a6

Browse files
krzyzakppaulfantom
authored andcommitted
Few smaller improvements, backward compatible (#110)
* Replaced tag always, which colidate when including role. Renamed tags, to include service name, for better handling with other roles * Updating molecule command, basing on official docs for latest version * Installing older pytest, which is not broken * Fixed module name typo * Fixed check_mode, to work smoothly. Added environment param, so you can set ie. http_proxy for getting GPG key. Added possibility to skip managing dashboards. * Fixed skipping environment when not setup * Updated README with new configuration params * Removed unnecessary variable for managing dashboards * Fixed pattern for templates
1 parent d66a434 commit c8648a6

File tree

5 files changed

+14
-1
lines changed

5 files changed

+14
-1
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ All variables which can be overridden are stored in [defaults/main.yml](defaults
5252
| `grafana_dashboards` | [] | List of dashboards which should be imported |
5353
| `grafana_dashboards_dir` | "dashboards" | Path to a local directory containing dashboards files in `json` format |
5454
| `grafana_datasources` | [] | List of datasources which should be configured |
55+
| `grafana_environment` | {} | Optional Environment param for Grafana installation, usefull ie for setting http_proxy |
5556

5657
Datasource example:
5758

defaults/main.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ grafana_image_storage: {}
170170
# Plugins from https://grafana.com/plugins
171171
grafana_plugins: []
172172
# - raintank-worldping-app
173-
#
173+
174174
# Dashboards from https://grafana.com/dashboards
175175
grafana_dashboards: []
176176
# - dashboard_id: '4271'
@@ -219,3 +219,5 @@ grafana_api_keys: []
219219

220220
# The location where the keys should be stored.
221221
grafana_api_keys_dir: "{{ lookup('env', 'HOME') }}/grafana/keys"
222+
223+
grafana_environment: {}

tasks/dashboards.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
mode: 0755
88
delegate_to: localhost
99
run_once: true
10+
check_mode: false
1011

1112
# - name: download grafana dashboard from grafana.net to local folder
1213
# become: false
@@ -40,6 +41,7 @@
4041
when: grafana_dashboards | length > 0
4142
tags:
4243
- skip_ansible_lint
44+
check_mode: false
4345

4446
# As noted in [1] an exported dashboard replaces the exporter's datasource
4547
# name with a representative name, something like 'DS_GRAPHITE'. The name

tasks/install.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
delay: 2
5151
when:
5252
- ansible_pkg_mgr == "apt"
53+
environment: "{{ grafana_environment }}"
5354

5455
- name: Install Grafana
5556
package:

tasks/main.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,14 @@
7474
- grafana_configure
7575
- grafana_notifications
7676

77+
- name: "Check if there are any dashboards in {{ grafana_dashboards_dir }}"
78+
find:
79+
paths: "{{ grafana_dashboards_dir }}"
80+
patterns: '*.json'
81+
register: found_dashboards
82+
7783
- include: dashboards.yml
84+
when: grafana_dashboards | length > 0 or found_dashboards.matched > 0
7885
tags:
7986
- grafana_configure
8087
- grafana_dashboards

0 commit comments

Comments
 (0)