From: Zack Cerza Date: Thu, 20 Jul 2017 23:21:50 +0000 (-0700) Subject: Optionally use a different Grafana admin password X-Git-Tag: v1.0~39^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=1f952ee680eacd42546379d73a2ae2cd2ea76f5e;p=cephmetrics.git Optionally use a different Grafana admin password Signed-off-by: Zack Cerza --- diff --git a/ansible/roles/ceph-grafana/defaults/main.yml b/ansible/roles/ceph-grafana/defaults/main.yml index 7014cf4..855f007 100644 --- a/ansible/roles/ceph-grafana/defaults/main.yml +++ b/ansible/roles/ceph-grafana/defaults/main.yml @@ -6,6 +6,9 @@ defaults: replace_dashboards: true grafana: datasource: Local + # Note: changing this value won't update the password in Grafana itself; + # change it via the web UI and then override this value to reflect. + admin_password: admin graphite: service: "{{ 'graphite-web' if ansible_pkg_mgr == 'yum' else 'graphite-api' }}" web_port: "{{ graphite_port | default('8080') }}" diff --git a/ansible/roles/ceph-grafana/tasks/configure_grafana.yml b/ansible/roles/ceph-grafana/tasks/configure_grafana.yml index edaf5ac..e8250a0 100644 --- a/ansible/roles/ceph-grafana/tasks/configure_grafana.yml +++ b/ansible/roles/ceph-grafana/tasks/configure_grafana.yml @@ -26,6 +26,15 @@ line: "domain = {{ ansible_fqdn }}" tags: [ini] +- name: Set admin_password in grafana.ini + lineinfile: + dest: /etc/grafana/grafana.ini + regexp: "^admin_password = .*" + insertafter: "^;admin_password = .*" + line: "admin_password = {{ grafana.admin_password }}" + no_log: true + tags: [ini] + - include: grafana_plugins.yml when: devel_mode @@ -55,8 +64,8 @@ uri: url: http://localhost:3000/api/datasources method: POST - user: "{{ graphite.user }}" - password: "{{ graphite.password }}" + user: admin + password: "{{ grafana.admin_password }}" force_basic_auth: yes body_format: json body: "{{ grafana_data_source }}" @@ -70,7 +79,7 @@ url: "http://localhost:3000/api/datasources/id/{{ grafana.datasource }}" method: GET user: "{{ graphite.user }}" - password: "{{ graphite.password }}" + password: "{{ grafana.admin_password }}" force_basic_auth: yes register: grafana_data_source_id when: grafana_data_source_result is defined and grafana_data_source_result.status == 409 @@ -80,7 +89,7 @@ url: "http://localhost:3000/api/datasources/{{ grafana_data_source_id.json.id }}" method: PUT user: "{{ graphite.user }}" - password: "{{ graphite.password }}" + password: "{{ grafana.admin_password }}" force_basic_auth: yes body_format: json body: "{{ grafana_data_source }}" @@ -103,6 +112,7 @@ template: src: dashboard.yml dest: /tmp/dashboard.yml + mode: 0600 - name: Set dashupdate_cmd and dashboard_dir set_fact: diff --git a/ansible/roles/ceph-grafana/templates/dashboard.yml b/ansible/roles/ceph-grafana/templates/dashboard.yml index 4c07703..7360451 100644 --- a/ansible/roles/ceph-grafana/templates/dashboard.yml +++ b/ansible/roles/ceph-grafana/templates/dashboard.yml @@ -16,6 +16,6 @@ _dashboards: - osd-node-detail _credentials: user: admin - password: admin + password: {{ grafana.admin_password }} _grafana_port: 3000 _home_dashboard: ceph-at-a-glance