]> git-server-git.apps.pok.os.sepia.ceph.com Git - cephmetrics.git/commitdiff
Optionally use a different Grafana admin password 81/head
authorZack Cerza <zack@redhat.com>
Thu, 20 Jul 2017 23:21:50 +0000 (16:21 -0700)
committerZack Cerza <zack@redhat.com>
Fri, 21 Jul 2017 21:48:53 +0000 (14:48 -0700)
Signed-off-by: Zack Cerza <zack@redhat.com>
ansible/roles/ceph-grafana/defaults/main.yml
ansible/roles/ceph-grafana/tasks/configure_grafana.yml
ansible/roles/ceph-grafana/templates/dashboard.yml

index 7014cf4e8172884930bf7a1a3638360dcfc2a242..855f007b2a43739daecb3360a005e316ae457333 100644 (file)
@@ -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') }}"
index edaf5ac8f1ae8292dd9ade60a721cec2e77198b5..e8250a0cb6af6a54ee4e27c8790b018af92de706 100644 (file)
     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 }}"
   template:
     src: dashboard.yml
     dest: /tmp/dashboard.yml
+    mode: 0600
 
 - name: Set dashupdate_cmd and dashboard_dir
   set_fact:
index 4c07703ceb2b8ad867153154da5c30dda18e4ce4..736045186d7f1bc0f147a9641bd615b645332460 100644 (file)
@@ -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