Skip to content

Commit

Permalink
PMM-12576 change admin ID to 1. (#2551)
Browse files Browse the repository at this point in the history
* PMM-12576 change admin ID to 1.

* PMM-12576 Debug messages.
  • Loading branch information
BupycHuk authored Oct 17, 2023
1 parent 578bab3 commit 9564347
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
17 changes: 14 additions & 3 deletions update/ansible/playbook/tasks/roles/initialization/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions update/ansible/playbook/tasks/update.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 9564347

Please sign in to comment.