atosatto.grafana

Ansible角色:Grafana

构建状态 Galaxy

安装和配置Grafana。

要求

需要Ansible 2.2或更高版本。

角色变量

可用变量如下,并附有默认值(请参见defaults/main.yml):

grafana_install_repo: "{{ grafana_repo_stable }}"

从中获取Grafana软件包的APT/YUM仓库。 默认情况下,使用vars/main.yml中定义的官方稳定仓库。

grafana_release_tag: ""

要安装的Grafana版本标签。 设置为“latest”以安装最新的稳定版本(请参见https://github.com/grafana/grafana/releases)。

grafana_user: "grafana"
grafana_group: "grafana"

Grafana的系统用户和组。

grafana_admin_user: "admin"
grafana_admin_password: "admin"

Grafana管理员用户名和凭证。

grafana_paths_data: "/var/lib/grafana"

Grafana临时文件、会话和sqlite3数据库的位置。

grafana_paths_logs: "/var/log/grafana"

Grafana日志文件的位置。

grafana_paths_plugins: "/var/lib/grafana/plugins"

Grafana将自动扫描并查找插件的目录。

grafana_paths_provisioning: "/etc/grafana/provisioning"

Grafana在启动时应用的配置文件的位置。此功能仅在Grafana >= 5.0可用。 有关更多信息,请参见http://docs.grafana.org/administration/provisioning/。

grafana_server_http_addr: ""

Grafana将绑定的IP地址。默认情况下,它将绑定到所有接口。

grafana_server_http_port: "3000"

Grafana将绑定的端口。

grafana_server_root_url: "http://localhost:3000"

从网页浏览器访问Grafana的完整URL。 在使用OAUTH身份验证时这一点很重要。

grafana_server_router_logging: "false"

设置为true,Grafana将记录所有HTTP请求(不仅仅是错误)。这些将作为信息级事件记录到Grafana日志中。

grafana_database_type: "sqlite3"
grafana_database_host: "127.0.0.1:3306"
grafana_database_name: "grafana"
grafana_database_user: "root"
grafana_database_password: ""
grafana_database_ssl_mode: "disable"
grafana_database_path: "grafana.db"

配置Grafana数据库以存储用户和仪表板。 默认情况下,将配置和使用sqlite3

grafana_dashboards_versions_to_keep: "20"

要保留的Grafana仪表板版本数量。

grafana_users_allow_sign_up: "false"

设置为true以允许用户注册/创建账户。

grafana_users_allow_org_create: "false"

设置为true以允许用户创建新组织。

grafana_users_auto_assign_org: "false"

设置为true以自动将新用户添加到指定的组织。

grafana_users_auto_assign_org_id: "1"

设置此值以自动将新用户添加到指定的组织。

grafana_users_auto_assign_org_role: "Viewer"

如果grafana_users_auto_assign_org设置为true,新用户在指定组织中将被分配的角色。

grafana_auth_disable_login_form: "false"

设置为true以禁用(隐藏)登录表单,如果您使用OAuth,这一点很有用。

grafana_auth_anonymous_enabled: "false"
grafana_auth_anonymous_org_name: "Main Org."
grafana_auth_anonymous_org_role: "Viewer"

匿名访问配置。

grafana_auth_github_enabled: "false"
grafana_auth_github_allow_sign_up: "true"
grafana_auth_github_client_id: "some_id"
grafana_auth_github_client_secret: "some_secret"
grafana_auth_github_scopes: "user:email,read:org"
grafana_auth_github_auth_url: "https://github.com/login/oauth/authorize"
grafana_auth_github_token_url: "https://github.com/login/oauth/access_token"
grafana_auth_github_api_url: "https://api.github.com/user"
grafana_auth_github_team_ids: ""
grafana_auth_github_allowed_organizations: ""

GitHub OAuth配置。

grafana_auth_google_enabled: "false"
grafana_auth_google_allow_sign_up: "true"
grafana_auth_google_client_id: "some_id"
grafana_auth_google_client_secret: "some_secret"
grafana_auth_google_scopes: "https://www.googleapis.com/auth/userinfo.profile https://www.googleapis.com/auth/userinfo.email"
grafana_auth_google_auth_url: "https://accounts.google.com/o/oauth2/auth"
grafana_auth_google_token_url: "https://accounts.google.com/o/oauth2/token"
grafana_auth_google_api_url: "https://www.googleapis.com/oauth2/v1/userinfo"
grafana_auth_google_allowed_domains: ""

Google OAuth配置。

grafana_auth_generic_oauth_enabled: "false"
grafana_auth_generic_oauth_name: "OAuth"
grafana_auth_generic_oauth_allow_sign_up: "true"
grafana_auth_generic_oauth_client_id: "some_id"
grafana_auth_generic_oauth_client_secret: "some_secret"
grafana_auth_generic_oauth_scopes: "user:email,read:org"
grafana_auth_generic_oauth_auth_url: "https://foo.bar/login/oauth/authorize"
grafana_auth_generic_oauth_token_url: "https://foo.bar/login/oauth/access_token"
grafana_auth_generic_oauth_api_url: "https://foo.bar/user"
grafana_auth_generic_oauth_team_ids: ""
grafana_auth_generic_oauth_allowed_organizations: ""

通用OAuth配置。

grafana_smtp_enabled: "false"
grafana_smtp_host: "localhost:25"
grafana_smtp_user: ""
grafana_smtp_password: ""
grafana_smtp_cert_file: ""
grafana_smtp_key_file: ""
grafana_smtp_skip_verify: "false"
grafana_smtp_from_address: "[email protected]"
grafana_smtp_from_name: "Grafana"

邮件服务器设置。

grafana_log_mode: "console file"

可以是consolefilesyslog。用空格分隔多个模式。

grafana_log_level: "info"

可以是debuginfowarnerrorcritical

grafana_alerting_enabled: "true"

设置为false以禁用警报引擎并在UI中隐藏警报。

grafana_alerting_execute_alerts: "true"

可以关闭警报规则的执行。

grafana_datasources: []
# grafana_datasources:
# - name: "prometheus"
#   type: "prometheus"
#   access: "proxy"
#   url: "http://127.0.0.1:9090"
#   basicAuth: "false"

通过http://docs.grafana.org/administration/provisioning/#datasources自动提供Grafana数据源。 注意: 此功能需要Grafana >= 5.0

grafana_dashboards: []
# grafana_dasboards:
# - name: "prometheus"
#   orgId: 1
#   folder: ""
#   type: file
#   disableDeletion: false
#   updateIntervalSeconds: 3
#   editable: true
#   options:
#     path: /var/lib/grafana/dashboards

通过http://docs.grafana.org/administration/provisioning/#dashboards自动提供Grafana仪表板。 上面的示例将配置Grafana自动加载/var/lib/grafana/dashboards中可用的任何仪表板。

依赖项

无。

示例剧本

$ cat playbook.yml
- name: "安装和配置Grafana"
  hosts: all
  roles:
    - { role: atosatto.grafana }

测试

测试由Molecule自动化。

$ pip install tox

要测试所有场景,请运行

$ tox

要运行自定义的molecule命令

$ tox -e py27-ansible29 -- molecule test -s grafana-latest

许可

MIT

作者信息

Andrea Tosatto (@_hilbert_)

关于项目

Install and configure Grafana

安装
ansible-galaxy install atosatto.grafana
许可证
mit
下载
1.8k
拥有者
Automation fan-boy. Head in the ☁️. Loving Containers, Micro-Services, OpenSource, Golang and Python