-
Notifications
You must be signed in to change notification settings - Fork 138
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/v3-api-breaking-changes' into PM…
- Loading branch information
Showing
83 changed files
with
1,051 additions
and
1,231 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,6 +22,7 @@ on: | |
jobs: | ||
build: | ||
name: Build | ||
if: false | ||
|
||
strategy: | ||
fail-fast: false | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,7 @@ | |
|
||
daemon off; | ||
|
||
error_log stderr info; | ||
error_log /dev/stderr info; | ||
# error_log stderr debug; | ||
|
||
events { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# This is the default ansible.cfg file. | ||
# It necessary for ansible to work properly when it acts as 'pmm' user. | ||
# Otherwise, it will fail with 'Permission denied' error since the default paths are '/root/.ansible/tmp' | ||
# Ref: https://github.com/ansible/ansible/blob/stable-2.9/examples/ansible.cfg | ||
[defaults] | ||
|
||
remote_tmp = /tmp | ||
local_tmp = /tmp | ||
|
||
# additional paths to search for roles in, colon separated | ||
roles_path = /opt/ansible/roles |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,196 @@ | ||
--- | ||
# This playbook contains tasks executed during PMM Server update. | ||
- hosts: localhost | ||
become: true | ||
remote_user: root | ||
gather_facts: true | ||
|
||
environment: | ||
PATH: /usr/local/bin:{{ ansible_env.PATH }} | ||
|
||
pre_tasks: | ||
- name: Detect /srv/pmm-distribution | ||
stat: | ||
path: /srv/pmm-distribution | ||
no_log: true | ||
register: srv_pmm_distribution | ||
|
||
- name: Detect container environment | ||
set_fact: | ||
is_docker: '{{ lookup("file", "/srv/pmm-distribution") == "docker" }}' | ||
no_log: true | ||
when: srv_pmm_distribution.stat.exists | ||
|
||
- name: Set the variable to true if undefined | ||
set_fact: | ||
is_docker: true | ||
when: is_docker is undefined | ||
|
||
tasks: | ||
- name: Enable maintenance mode | ||
copy: | ||
src: maintenance.html | ||
dest: /usr/share/pmm-server/maintenance/ | ||
owner: pmm | ||
group: pmm | ||
mode: 0644 | ||
|
||
# restart pmm-managed-init and pmm-managed first as they may update supervisord configuration on start | ||
- name: Generate new supervisor config | ||
command: pmm-managed-init | ||
register: managed_init_result | ||
changed_when: True | ||
|
||
- name: Disable pmm-update-perform-init | ||
ini_file: | ||
path: /etc/supervisord.d/pmm.ini | ||
section: program:pmm-update-perform-init | ||
option: autostart | ||
value: "false" | ||
|
||
- name: Check that supervisor socket exists | ||
stat: | ||
path: /run/supervisor/supervisor.sock | ||
register: supervisor_socket | ||
|
||
# During build time, this will be the first start of supervisord. | ||
- name: Start supervisord | ||
when: not supervisor_socket.stat.exists | ||
shell: supervisord -c /etc/supervisord.conf & | ||
|
||
- name: Wait until postgres port is present | ||
wait_for: | ||
host: localhost | ||
port: 5432 | ||
timeout: 150 | ||
|
||
- name: Run initialization playbook | ||
include_role: | ||
name: initialization | ||
|
||
# See https://github.com/Supervisor/supervisor/issues/1264 for explanation | ||
# why we do reread + stop/remove/add instead of using supervisorctl Ansible module. | ||
- name: Reread supervisord configuration | ||
command: supervisorctl reread | ||
become: true | ||
become_user: pmm | ||
become_method: su | ||
register: reread_result | ||
changed_when: "'No config updates to processes' not in reread_result.stdout" | ||
|
||
- name: Check reread results | ||
debug: var=reread_result.stdout_lines | ||
|
||
- name: Restart pmm-managed | ||
command: "supervisorctl {{ item }} pmm-managed" | ||
become: true | ||
become_user: pmm | ||
become_method: su | ||
loop: | ||
- stop | ||
- remove | ||
- add | ||
|
||
# Give pmm-managed time to update supervisord configuration, | ||
# and give update UI time to catch up after pmm-managed restart | ||
- name: Wait for pmm-managed | ||
pause: seconds=10 | ||
|
||
# Fix things that should be fixed before restarts. | ||
|
||
- name: Reread supervisord configuration again | ||
command: supervisorctl reread | ||
register: reread_result | ||
changed_when: "'No config updates to processes' not in reread_result.stdout" | ||
|
||
- name: Check reread results | ||
debug: var=reread_result.stdout_lines | ||
|
||
- name: Restart services | ||
command: supervisorctl {{ item.1 }} {{ item.0 }} | ||
become: true | ||
become_user: pmm | ||
become_method: su | ||
# changed_when: true | ||
with_nested: | ||
- - nginx | ||
- grafana | ||
- qan-api2 | ||
- pmm-agent | ||
- ["stop", "remove", "add"] | ||
|
||
- name: Check supervisord logs | ||
shell: sleep 10 && tail -n 200 /srv/logs/supervisord.log | ||
|
||
- name: Check grafana logs | ||
shell: cat /srv/logs/grafana.log | ||
|
||
- 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: Change default admin id | ||
postgresql_query: | ||
db: grafana | ||
query: UPDATE "user" SET id='1' WHERE login='admin'; | ||
when: not ansible_check_mode | ||
|
||
# - name: Remove redundant packages | ||
# yum: | ||
# state: absent | ||
# name: | ||
# - logrotate # https://jira.percona.com/browse/PMM-7627 | ||
|
||
# Regenerating pmm.ini and enabling pmm-update-perform-init | ||
- name: Generate new supervisor config | ||
command: pmm-managed-init | ||
become: true | ||
become_user: pmm | ||
become_method: su | ||
register: managed_init_result | ||
changed_when: True | ||
|
||
- name: Reread pmm-update-perform-init supervisor config | ||
command: supervisorctl reread | ||
register: reread_init__result | ||
changed_when: "'No config updates to processes' not in reread_init__result.stdout" | ||
|
||
- name: Update/restart other services | ||
command: supervisorctl update | ||
register: update_result | ||
changed_when: "'updated' in update_result.stdout" | ||
|
||
- name: Print other services's logs | ||
debug: var=update_result.stdout_lines | ||
|
||
- name: Wait for PMM to be ready | ||
ansible.builtin.uri: | ||
url: "http://127.0.0.1:7772/v1/readyz" | ||
status_code: 200 | ||
method: GET | ||
register: healthcheck | ||
until: healthcheck is not failed | ||
retries: 120 | ||
delay: 1 | ||
|
||
# SIGUSR2 is sent to supervisord by pmm-managed right before the update for logging to work correctly. | ||
# We use that fact to show what was restarted during the update. | ||
- name: Get supervisord logs | ||
shell: supervisorctl maintail -100000 | tac | awk '!flag; /received SIGUSR2/{flag = 1};' | tac | ||
register: maintail_result | ||
changed_when: False | ||
|
||
- name: Print supervisord logs | ||
debug: var=maintail_result.stdout_lines | ||
|
||
- name: Disable maintenance mode | ||
file: | ||
state: absent | ||
path: /usr/share/pmm-server/maintenance/maintenance.html |
1 change: 1 addition & 0 deletions
1
update/ansible/playbook/tasks/create-lvm.yml → build/ansible/pmm/create-lvm.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
Oops, something went wrong.