From 95643477e07061897bffa10adebf34198429626c Mon Sep 17 00:00:00 2001 From: Nurlan Moldomurov Date: Tue, 17 Oct 2023 12:36:37 +0300 Subject: [PATCH] PMM-12576 change admin ID to 1. (#2551) * PMM-12576 change admin ID to 1. * PMM-12576 Debug messages. --- .../tasks/roles/initialization/tasks/main.yml | 17 ++++++++++++++--- update/ansible/playbook/tasks/update.yml | 6 ++++++ 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/update/ansible/playbook/tasks/roles/initialization/tasks/main.yml b/update/ansible/playbook/tasks/roles/initialization/tasks/main.yml index c3cc50d5f0..021b246b2b 100644 --- a/update/ansible/playbook/tasks/roles/initialization/tasks/main.yml +++ b/update/ansible/playbook/tasks/roles/initialization/tasks/main.yml @@ -38,7 +38,11 @@ # and we use pmm_current_version is version(pmm_image_version, '>=') to run it only if upgrade is required - name: Determine type of upgrade set_fact: - docker_upgrade: not ui_upgrade and current_version_file['failed'] == false and not pmm_current_version is version(pmm_image_version, '>=') + docker_upgrade: "{{ not ui_upgrade and current_version_file['failed'] != true and not pmm_current_version is version(pmm_image_version, '>=') }}" + +- name: Print Docker upgrade fact + debug: + msg: "Docker upgrade: {{ docker_upgrade }}" # We use current_version_file['failed'] because we don't want to run this on creating container # and we use pmm_current_version is version(pmm_image_version, '>=') to run it only if upgrade is required @@ -104,14 +108,14 @@ - name: Create empty configuration file for VictoriaMetrics file: path=/etc/victoriametrics-promscrape.yml state=touch owner=pmm group=pmm -- name: Run SQLite -> Postgres only for docker upgrade +- name: Run operations for docker-way upgrade block: - name: Check that the SQLite grafana database exists stat: path: /srv/grafana/grafana.db register: is_database_sqlite - - name: Temporary change database to SQLite + - name: Run SQLite -> Postgres only block: - name: Remove database options (SQLite is default) ini_file: @@ -159,6 +163,13 @@ tags: - skip_ansible_lint # '503 Tasks that run when changed should likely be handlers'. when: is_database_sqlite.stat.exists + + - name: Change default admin id + postgresql_query: + db: grafana + query: UPDATE "user" SET id='1' WHERE login='admin'; + when: not ansible_check_mode + when: docker_upgrade - name: Check if we need an update or not diff --git a/update/ansible/playbook/tasks/update.yml b/update/ansible/playbook/tasks/update.yml index 61ae3a43a2..a4ebee9290 100644 --- a/update/ansible/playbook/tasks/update.yml +++ b/update/ansible/playbook/tasks/update.yml @@ -409,6 +409,12 @@ - ALTER TABLE api_key ALTER COLUMN name TYPE text; when: not ansible_check_mode + - name: Change default admin id + postgresql_query: + db: grafana + query: UPDATE "user" SET id='1' WHERE login='admin'; + when: not ansible_check_mode + # we need to put this step as one of the last steps, because it removes pmm.ini and /etc/alertmanager.yml - name: Remove old or redundant packages yum: