Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PMM-12576 change admin ID to 1. #2551

Merged
merged 2 commits into from
Oct 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO, this is unnecessary during the initialization phase, PMM is going to run the update part down below on every restart or upgrade.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I answered in the other PR that this will run only on upgrade, because of condition below for the whole block

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I disagree, but commit :)

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
Loading