86 lines
3.7 KiB
YAML
86 lines
3.7 KiB
YAML
---
|
|
- name: Check variable types
|
|
assert:
|
|
that:
|
|
- grafana_server is mapping
|
|
- grafana_database is mapping
|
|
- grafana_security is mapping
|
|
|
|
- name: Fail when datasources aren't configured when dashboards are set to be installed
|
|
fail:
|
|
msg: "You need to specify datasources for dashboards!!!"
|
|
when: grafana_dashboards != [] and grafana_datasources == []
|
|
|
|
- name: Fail when grafana admin user isn't set
|
|
fail:
|
|
msg: "Please specify grafana admin user (grafana_security.admin_user)"
|
|
when:
|
|
- grafana_security.admin_user == '' or
|
|
grafana_security.admin_user is not defined
|
|
|
|
- name: Fail when grafana admin password isn't set
|
|
fail:
|
|
msg: "Please specify grafana admin password (grafana_security.admin_password)"
|
|
when:
|
|
- grafana_security.admin_password == '' or
|
|
grafana_security.admin_password is not defined
|
|
|
|
- name: Fail on incorrect variable types in datasource definitions
|
|
fail:
|
|
msg: "Boolean variables in grafana_datasources shouldn't be passed as strings. Please remove unneeded apostrophes."
|
|
when: ( item.isDefault is defined and item.isDefault is string ) or
|
|
( item.basicAuth is defined and item.basicAuth is string )
|
|
with_items: "{{ grafana_datasources }}"
|
|
|
|
- name: Fail on bad database configuration
|
|
fail:
|
|
msg: "Wrong database configuration. Please look at http://docs.grafana.org/installation/configuration/#database"
|
|
when: ( grafana_database.type == "sqlite3" and grafana_database.url is defined ) or
|
|
( grafana_database.type != "sqlite3" and grafana_database.path is defined ) or
|
|
( grafana_database.type == "sqlite3" and grafana_database.host is defined ) or
|
|
( grafana_database.type == "sqlite3" and grafana_database.user is defined ) or
|
|
( grafana_database.type == "sqlite3" and grafana_database.password is defined ) or
|
|
( grafana_database.type == "sqlite3" and grafana_database.server_cert_name is defined )
|
|
|
|
- name: Fail when grafana domain isn't properly configured
|
|
fail:
|
|
msg: "Check server configuration. Please look at http://docs.grafana.org/installation/configuration/#server"
|
|
when:
|
|
- grafana_server.root_url is defined
|
|
- grafana_server.root_url is search(grafana_server.domain)
|
|
|
|
- name: Fail when grafana_api_keys uses invalid role names
|
|
fail:
|
|
msg: "Check grafana_api_keys. The role can only be one of the following values: Viewer, Editor or Admin."
|
|
when:
|
|
- item.role not in ['Viewer', 'Editor', 'Admin']
|
|
with_items: "{{ grafana_api_keys }}"
|
|
|
|
- name: Fail when grafana_ldap isn't set when grafana_auth.ldap is
|
|
fail:
|
|
msg: "You need to configure grafana_ldap.servers and grafana_ldap.group_mappings when grafana_auth.ldap is set"
|
|
when:
|
|
- "'ldap' in grafana_auth"
|
|
- grafana_ldap is not defined or ('servers' not in grafana_ldap or 'group_mappings' not in grafana_ldap)
|
|
|
|
- name: Force grafana_use_provisioning to false if grafana_version is < 5.0 ( grafana_version is set to '{{ grafana_version }}' )
|
|
set_fact:
|
|
grafana_use_provisioning: false
|
|
when:
|
|
- grafana_version != 'latest'
|
|
- grafana_version is version_compare('5.0', '<')
|
|
|
|
- name: Fail if grafana_port is lower than 1024 and grafana_cap_net_bind_service is not true
|
|
fail:
|
|
msg: Trying to use a port lower than 1024 without setting grafana_cap_net_bind_service.
|
|
when:
|
|
- grafana_port | int <= 1024
|
|
- not grafana_cap_net_bind_service
|
|
|
|
- name: Fail if grafana_server.socket not defined when in socket mode
|
|
fail:
|
|
msg: "You need to configure grafana_server.socket when grafana_server.protocol is set to 'socket'"
|
|
when:
|
|
- grafana_server.protocol is defined and grafana_server.protocol == 'socket'
|
|
- grafana_server.socket is undefined or grafana_server.socket == ''
|