diff --git a/update/ansible/playbook/tasks/roles/initialization/tasks/main.yml b/update/ansible/playbook/tasks/roles/initialization/tasks/main.yml index 15cba26e6f..2476b13d68 100644 --- a/update/ansible/playbook/tasks/roles/initialization/tasks/main.yml +++ b/update/ansible/playbook/tasks/roles/initialization/tasks/main.yml @@ -173,6 +173,6 @@ state: absent path: /usr/share/pmm-server/maintenance/maintenance.html # We use current_version_file['failed'] because we don't want to run this on creating container - when: not ui_upgrade and current_version_file['failed'] == false + when: not ui_upgrade and current_version_file['failed'] == false and not pmm_current_version is version(pmm_image_version, '>=') diff --git a/update/ansible/playbook/tasks/update.yml b/update/ansible/playbook/tasks/update.yml index eb5b440227..ffddbc123e 100644 --- a/update/ansible/playbook/tasks/update.yml +++ b/update/ansible/playbook/tasks/update.yml @@ -397,6 +397,29 @@ - /etc/yum/yum-cron-hourly.conf - /etc/yum/yum-cron.conf + - name: Check that the SQLite grafana database exists + stat: + path: /srv/grafana/grafana.db + register: is_database_sqlite + + - name: Migrate Grafana database from SQLite to Postgresql + include_role: + name: sqlite-to-postgres + when: is_database_sqlite.stat.exists + tags: + - skip_ansible_lint # '503 Tasks that run when changed should likely be handlers'. + + - name: Fix grafana fields type + postgresql_query: + db: grafana + query: "{{ item }}" + loop: + - ALTER TABLE tag ALTER COLUMN key TYPE text; + - ALTER TABLE tag ALTER COLUMN value TYPE text; + - ALTER TABLE api_key ALTER COLUMN key TYPE text; + - ALTER TABLE api_key ALTER COLUMN name TYPE text; + when: not ansible_check_mode + # Regenerating to enable pmm-update-perform-init - name: Generate new supervisor config command: pmm-managed-init @@ -430,29 +453,6 @@ - name: Print other services's logs debug: var=update_result.stdout_lines - - name: Check that the SQLite grafana database exists - stat: - path: /srv/grafana/grafana.db - register: is_database_sqlite - - - name: Migrate Grafana database from SQLite to Postgresql - include_role: - name: sqlite-to-postgres - when: is_database_sqlite.stat.exists - tags: - - skip_ansible_lint # '503 Tasks that run when changed should likely be handlers'. - - - name: Fix grafana fields type - postgresql_query: - db: grafana - query: "{{ item }}" - loop: - - ALTER TABLE tag ALTER COLUMN key TYPE text; - - ALTER TABLE tag ALTER COLUMN value TYPE text; - - ALTER TABLE api_key ALTER COLUMN key TYPE text; - - ALTER TABLE api_key ALTER COLUMN name TYPE text; - when: not ansible_check_mode - - name: Wait for PMM to be ready ansible.builtin.uri: url: "http://127.0.0.1:7772/v1/readyz"