From: Zack Cerza Date: Thu, 5 Oct 2017 19:43:57 +0000 (-0600) Subject: Use --fake-initial for migrations if necessary X-Git-Tag: v1.0~9^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F137%2Fhead;p=cephmetrics.git Use --fake-initial for migrations if necessary 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 --- diff --git a/ansible/roles/ceph-grafana/tasks/configure_graphite_web.yml b/ansible/roles/ceph-grafana/tasks/configure_graphite_web.yml index a516156..dc07a92 100644 --- a/ansible/roles/ceph-grafana/tasks/configure_graphite_web.yml +++ b/ansible/roles/ceph-grafana/tasks/configure_graphite_web.yml @@ -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] }}"