From 7ce1f93b679c7d826c5c8fc6a76382bf2dc07df4 Mon Sep 17 00:00:00 2001 From: Zack Cerza Date: Thu, 5 Oct 2017 13:43:57 -0600 Subject: [PATCH] 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 --- .../roles/ceph-grafana/tasks/configure_graphite_web.yml | 7 +++++++ 1 file changed, 7 insertions(+) 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] }}" -- 2.47.3