]> git-server-git.apps.pok.os.sepia.ceph.com Git - cephmetrics.git/commitdiff
Use --fake-initial for migrations if necessary 137/head
authorZack Cerza <zack@redhat.com>
Thu, 5 Oct 2017 19:43:57 +0000 (13:43 -0600)
committerZack Cerza <zack@redhat.com>
Thu, 5 Oct 2017 20:36:22 +0000 (14:36 -0600)
Migrations won't work correctly if the db already exists. This manifests
in an error like:
django.db.utils.OperationalError: table "django_content_type" already exists

Signed-off-by: Zack Cerza <zack@redhat.com>
ansible/roles/ceph-grafana/tasks/configure_graphite_web.yml

index a516156539c6ec9a88d5f552b2d932754575372c..dc07a9289fa7a5a4a8a6cd195c51fc20aceca7dd 100644 (file)
@@ -2,6 +2,13 @@
 - name: Create Graphite DB tables
   command: /usr/bin/graphite-manage migrate --noinput
   become_user: "{{ graphite.unix_user[ansible_pkg_mgr] }}"
+  register: migrate_cmd
+  failed_when: migrate_cmd.rc != 0 and 'table "django_content_type" already exists' not in migrate_cmd.stderr
+
+- name: Run Graphite migrations if necessary
+  command: /usr/bin/graphite-manage migrate --noinput --fake-initial
+  become_user: "{{ graphite.unix_user[ansible_pkg_mgr] }}"
+  when: migrate_cmd.rc != 0
 
 - name: Build Graphite index
   command: "{{ graphite.build_index[ansible_pkg_mgr] }}"