diff --git a/.github/workflows/update.yml b/.github/workflows/update.yml
index f3b23fc9e2..3e1798e250 100644
--- a/.github/workflows/update.yml
+++ b/.github/workflows/update.yml
@@ -22,6 +22,7 @@ on:
jobs:
build:
name: Build
+ if: false
strategy:
fail-fast: false
diff --git a/README.md b/README.md
index 6d9fe88694..6419a781c3 100644
--- a/README.md
+++ b/README.md
@@ -57,7 +57,7 @@ $ docker volume create pmm-data
3. Run PMM server container
```bash
$ docker run --detach --restart always \
---publish 443:443 \
+--publish 443:8443 \
--volume pmm-data:/srv \
--name pmm-server \
percona/pmm-server:3
@@ -99,4 +99,4 @@ As a general rule of thumb, please try to create bug reports that are:
## Licensing
-Percona is dedicated to **keeping open source open**. Wherever possible, we strive to include permissive licensing for both our software and documentation. For this project, we are using the [GNU AGPLv3](https://github.com/percona/pmm/blob/main/LICENSE) license.
+Percona is dedicated to **keeping open source open**. Wherever possible, we strive to include permissive licensing for both our software and documentation. For this project, we are using the [GNU AGPLv3](./LICENSE) license.
diff --git a/admin/commands/pmm/server/docker/install.go b/admin/commands/pmm/server/docker/install.go
index a0e7c9f147..c40f221d3d 100644
--- a/admin/commands/pmm/server/docker/install.go
+++ b/admin/commands/pmm/server/docker/install.go
@@ -129,8 +129,8 @@ func (c *InstallCommand) runContainer(ctx context.Context, volume *volume.Volume
logrus.Info("Starting PMM Server")
ports := nat.PortMap{
- "443/tcp": []nat.PortBinding{{HostIP: "0.0.0.0", HostPort: strconv.Itoa(int(c.HTTPSListenPort))}},
- "80/tcp": []nat.PortBinding{{HostIP: "0.0.0.0", HostPort: strconv.Itoa(int(c.HTTPListenPort))}},
+ "8443/tcp": []nat.PortBinding{{HostIP: "0.0.0.0", HostPort: strconv.Itoa(int(c.HTTPSListenPort))}},
+ "8080/tcp": []nat.PortBinding{{HostIP: "0.0.0.0", HostPort: strconv.Itoa(int(c.HTTPListenPort))}},
}
containerID, err := startPMMServer(ctx, volume, "", dockerImage, c.dockerFn, ports, c.ContainerName)
diff --git a/agent/Makefile b/agent/Makefile
index c170223a4d..34921df996 100644
--- a/agent/Makefile
+++ b/agent/Makefile
@@ -11,7 +11,7 @@ PMM_RELEASE_VERSION ?= $(shell git describe --always --dirty | cut -b2-)
PMM_RELEASE_TIMESTAMP ?= $(shell date '+%s')
PMM_RELEASE_FULLCOMMIT ?= $(shell git rev-parse HEAD)
PMM_RELEASE_BRANCH ?= $(shell git describe --always --contains --all)
-PMM_DEV_SERVER_PORT ?= 443
+PMM_DEV_SERVER_PORT ?= 8443
ifeq ($(GOBIN),)
GOBIN := $(shell go env GOPATH)/bin
endif
diff --git a/agent/agents/supervisor/supervisor_test.go b/agent/agents/supervisor/supervisor_test.go
index be5ae9268f..4919241dc6 100644
--- a/agent/agents/supervisor/supervisor_test.go
+++ b/agent/agents/supervisor/supervisor_test.go
@@ -52,7 +52,7 @@ func TestSupervisor(t *testing.T) {
cfgStorage := config.NewStorage(&config.Config{
Paths: config.Paths{TempDir: tempDir},
Ports: config.Ports{Min: 65000, Max: 65099},
- Server: config.Server{Address: "localhost:443"},
+ Server: config.Server{Address: "localhost:8443"},
LogLinesCount: 1,
})
s := NewSupervisor(ctx, nil, cfgStorage)
diff --git a/agent/docker-compose.yml b/agent/docker-compose.yml
index 2b8c2e0d8a..1d0bc80557 100644
--- a/agent/docker-compose.yml
+++ b/agent/docker-compose.yml
@@ -6,8 +6,8 @@ services:
image: ${PMM_SERVER_IMAGE:-perconalab/pmm-server:3-dev-latest}
container_name: pmm-agent_pmm-server
ports:
- - "127.0.0.1:80:80"
- - "127.0.0.1:443:443"
+ - "127.0.0.1:80:8080"
+ - "127.0.0.1:443:8443"
environment:
- PMM_DEBUG=1
- PERCONA_TEST_CHECKS_INTERVAL=10s
diff --git a/api-tests/docker-compose.yml b/api-tests/docker-compose.yml
index a34895c4d7..b3452357cd 100644
--- a/api-tests/docker-compose.yml
+++ b/api-tests/docker-compose.yml
@@ -6,8 +6,8 @@ services:
image: ${PMM_SERVER_IMAGE:-perconalab/pmm-server:3-dev-latest}
container_name: pmm-agent_pmm-server
ports:
- - 127.0.0.1:80:80
- - 127.0.0.1:443:443
+ - 127.0.0.1:80:8080
+ - 127.0.0.1:443:8443
environment:
- PMM_DEBUG=1
- PERCONA_TEST_CHECKS_INTERVAL=10s
diff --git a/api-tests/server/settings_test.go b/api-tests/server/settings_test.go
index a7eb4b7bb1..b9ac8e7ead 100644
--- a/api-tests/server/settings_test.go
+++ b/api-tests/server/settings_test.go
@@ -507,7 +507,7 @@ func TestSettings(t *testing.T) {
assert.Empty(t, res)
})
- t.Run("NoAdminUserForSSH", func(t *testing.T) {
+ t.Run("ChangeSSHKey", func(t *testing.T) {
defer restoreSettingsDefaults(t)
sshKey := "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQClY/8sz3w03vA2bY6mBFgUzrvb2FIoHw8ZjUXGGClJzJg5HC" +
@@ -521,7 +521,7 @@ func TestSettings(t *testing.T) {
},
Context: pmmapitests.Context,
})
- pmmapitests.AssertAPIErrorf(t, err, 500, codes.Internal, `Internal server error.`)
+ require.NoError(t, err)
assert.Empty(t, res)
})
diff --git a/api-tests/server/version_test.go b/api-tests/server/version_test.go
index e8ea69f5a6..10b7c82174 100644
--- a/api-tests/server/version_test.go
+++ b/api-tests/server/version_test.go
@@ -34,7 +34,6 @@ import (
func TestVersion(t *testing.T) {
t.Parallel()
paths := []string{
- "managed/v1/version",
"v1/version",
}
for _, path := range paths {
diff --git a/api/nginx/nginx.conf b/api/nginx/nginx.conf
index 2e385864ba..730479d2a9 100644
--- a/api/nginx/nginx.conf
+++ b/api/nginx/nginx.conf
@@ -3,7 +3,7 @@
daemon off;
-error_log stderr info;
+error_log /dev/stderr info;
# error_log stderr debug;
events {
diff --git a/build/Makefile b/build/Makefile
index 4bf4ea0d83..8d87e996e2 100644
--- a/build/Makefile
+++ b/build/Makefile
@@ -66,36 +66,39 @@ pmm-ami:
-var 'pmm_client_repo_name=percona-experimental-x86_64' \
-var 'pmm_server_repo=experimental' \
-only amazon-ebs -color=false \
- packer/pmm.json
+ packer/pmm.json
pmm-ami-rc:
docker run --rm -v ${HOME}/.aws:/root/.aws -v `pwd`:/build -w /build hashicorp/packer:${PACKER_VERSION} \
build -var 'pmm_client_repos=original testing' \
- -var 'pmm_client_repo_name=percona-testing-x86_64' \
- -var 'pmm_server_repo=testing' \
- -only amazon-ebs '-color=false' \
- packer/pmm.json
+ -var 'pmm_client_repo_name=percona-testing-x86_64' \
+ -var 'pmm_server_repo=testing' \
+ -only amazon-ebs '-color=false' \
+ packer/pmm.json
pmm-ami-el9:
mkdir -p update && \
- cp -r ../update/ansible/playbook/* update/ && \
- sed -i 's|become_method: su|become_method: sudo|g' update/tasks/roles/postgres/tasks/main.yml && \
+ sed -i 's|become_method: su|become_method: sudo|g' ./roles/postgres/tasks/main.yml && \
docker run --rm -v ${HOME}/.aws:/root/.aws -v `pwd`:/build -w /build hashicorp/packer:${PACKER_VERSION} \
build -var 'pmm_client_repos=original experimental' \
-var 'pmm_client_repo_name=percona-experimental-x86_64' \
-var 'pmm_server_repo=experimental' \
-only amazon-ebs -color=false \
- packer/pmm.el9.json
+ packer/pmm.el9.json
pmm-ami-el9-rc:
mkdir -p update && \
- cp -r ../update/ansible/playbook/* update/ && \
- sed -i 's|become_method: su|become_method: sudo|g' update/tasks/roles/postgres/tasks/main.yml && \
- docker run --rm -v ${HOME}/.aws:/root/.aws -v `pwd`:/build -w /build hashicorp/packer:${PACKER_VERSION} \
- build -var 'pmm_client_repos=original testing' \
- -var 'pmm_client_repo_name=percona-testing-x86_64' \
+ sed -i 's|become_method: su|become_method: sudo|g' ./roles/postgres/tasks/main.yml && \
+ docker run --rm -v ${HOME}/.aws:/root/.aws -v `pwd`:/build -w /build hashicorp/packer:${PACKER_VERSION} \
+ build -var 'pmm_client_repos=original testing' \
+ -var 'pmm_client_repo_name=percona-testing-x86_64' \
-var 'pmm_server_repo=testing' \
- -only amazon-ebs '-color=false' \
- packer/pmm.el9.json
+ -only amazon-ebs '-color=false' \
+ packer/pmm.el9.json
## ----------------- PACKER ------------------
+
+check: ## Run required checkers and linters
+ ansible-playbook --syntax-check ansible/pmm-docker/update.yml
+ ansible-playbook --check ansible/pmm-docker/update.yml
+ ansible-lint ansible/pmm-docker/update.yml
diff --git a/update/.ansible-lint b/build/ansible/.ansible-lint
similarity index 100%
rename from update/.ansible-lint
rename to build/ansible/.ansible-lint
diff --git a/build/ansible/ansible.cfg b/build/ansible/ansible.cfg
new file mode 100644
index 0000000000..60507f8031
--- /dev/null
+++ b/build/ansible/ansible.cfg
@@ -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
diff --git a/update/ansible/playbook/tasks/files/maintenance.html b/build/ansible/pmm-docker/files/maintenance.html
similarity index 100%
rename from update/ansible/playbook/tasks/files/maintenance.html
rename to build/ansible/pmm-docker/files/maintenance.html
diff --git a/update/ansible/playbook/tasks/init.yml b/build/ansible/pmm-docker/init.yml
similarity index 58%
rename from update/ansible/playbook/tasks/init.yml
rename to build/ansible/pmm-docker/init.yml
index 5c27f29b2d..4eba8ceb66 100644
--- a/update/ansible/playbook/tasks/init.yml
+++ b/build/ansible/pmm-docker/init.yml
@@ -2,8 +2,10 @@
# This playbook contains tasks executed during initialization PMM Server
- hosts: localhost
become: true
+ become_method: su
+ become_user: pmm
gather_facts: true
- tasks:
- - name: Run initialization role
- include_role:
- name: initialization
+
+
+ roles:
+ - initialization
diff --git a/build/ansible/pmm-docker/update.yml b/build/ansible/pmm-docker/update.yml
new file mode 100644
index 0000000000..8189a721dd
--- /dev/null
+++ b/build/ansible/pmm-docker/update.yml
@@ -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
diff --git a/update/ansible/playbook/tasks/create-lvm.yml b/build/ansible/pmm/create-lvm.yml
similarity index 95%
rename from update/ansible/playbook/tasks/create-lvm.yml
rename to build/ansible/pmm/create-lvm.yml
index 93a072b38f..0126562c0a 100644
--- a/update/ansible/playbook/tasks/create-lvm.yml
+++ b/build/ansible/pmm/create-lvm.yml
@@ -1,3 +1,4 @@
+# TODO: This role seems to no longer be used. Verify and remove.
- hosts: localhost
become: true
gather_facts: true
diff --git a/update/ansible/playbook/tasks/files/cloud.cfg b/build/ansible/pmm/files/cloud.cfg
similarity index 100%
rename from update/ansible/playbook/tasks/files/cloud.cfg
rename to build/ansible/pmm/files/cloud.cfg
diff --git a/update/ansible/playbook/tasks/files/resize-xfs-lvm b/build/ansible/pmm/files/resize-xfs-lvm
similarity index 100%
rename from update/ansible/playbook/tasks/files/resize-xfs-lvm
rename to build/ansible/pmm/files/resize-xfs-lvm
diff --git a/update/ansible/playbook/tasks/supervisord.service b/build/ansible/pmm/files/supervisord.service
similarity index 100%
rename from update/ansible/playbook/tasks/supervisord.service
rename to build/ansible/pmm/files/supervisord.service
diff --git a/build/ansible/pmm/post-build-actions.yml b/build/ansible/pmm/post-build-actions.yml
index 6bbd831891..038e951b6a 100644
--- a/build/ansible/pmm/post-build-actions.yml
+++ b/build/ansible/pmm/post-build-actions.yml
@@ -1,124 +1,60 @@
---
-# This playbook is used as a post build actions for all pmm images (AMI/OVF/Docker).
+# This playbook runs post build tasks for all pmm distributions (AMI/OVF/Docker/Digitalocean).
-- hosts: localhost
+- hosts: all
become: yes
gather_facts: yes
vars:
pmm_client_repos: "original testing"
pmm_client_repos_final: "original release"
+ pmm_server_distribution: "docker"
tasks:
- # pmm-managed checks that if /srv/pmm-distribution exist, it contains "docker", "ovf", or "ami" (all lowercase)
- - name: Detect distribution | Create '/srv/pmm-distribution' file for Docker
- when: ansible_virtualization_type == "docker"
+ # pmm-managed checks that if /srv/pmm-distribution exists, it contains "docker", "ovf", "ami" or "digitalocean" - all lowercase.
+ # TODO: refactor the build pipelines to call post-build.yml with the distribution name provided in the variable (above).
+ # https://jira.percona.com/browse/PMM-4991
+ - name: Create a distribution file for Docker
copy:
- content: "docker"
- dest: /srv/pmm-distribution
-
- - name: Detect distribution | Create '/srv/pmm-distribution' file for OVF
- when: ansible_virtualization_type == "virtualbox"
- copy:
- content: "ovf"
- dest: /srv/pmm-distribution
-
- # TODO https://jira.percona.com/browse/PMM-4991
- - name: Detect distribution | Create '/srv/pmm-distribution' file for AMI
- when: >
- ( ansible_virtualization_type == "xen"
- or ansible_virtualization_type == "kvm" )
- and ansible_system_vendor != "DigitalOcean"
- copy:
- content: "ami"
- dest: /srv/pmm-distribution
-
- - name: Detect distribution | Create '/srv/pmm-distribution' file for DigitalOcean
- when: ansible_system_vendor == "DigitalOcean"
- copy:
- content: "digitalocean"
+ content: "{{ pmm_server_distribution}}"
dest: /srv/pmm-distribution
+ owner: pmm
+ group: pmm
- - name: Disable repo | Disable testing repo for pmm-client
+ - name: Disable testing repo for pmm-client
command: percona-release disable {{ pmm_client_repos }}
- - name: Enable repo | Enable release repo for pmm-client
+ - name: Enable release repo for pmm-client
command: percona-release enable {{ pmm_client_repos_final }}
- - name: Install glibc-langpack-en | EL9
- dnf:
- name: glibc-langpack-en
- state: present
- update_cache: yes
- when:
- - ansible_virtualization_type != "docker"
- - ansible_distribution == 'OracleLinux' or ansible_distribution == 'AlmaLinux'
- - ansible_distribution_major_version == '9'
-
- - name: Set locale to en_US.utf8 | EL9
- command: localectl set-locale LANG=en_US.utf8
- when:
- - ansible_virtualization_type != "docker"
- - ansible_distribution == 'OracleLinux' or ansible_distribution == 'AlmaLinux'
- - ansible_distribution_major_version == '9'
-
- - name: pmm-agent | Setup pmm-agent
+ - name: Set up pmm-agent
command: >
pmm-agent setup
--config-file=/usr/local/percona/pmm/config/pmm-agent.yaml
--skip-registration
--id=pmm-server
- --server-address=127.0.0.1:443
+ --server-address=127.0.0.1:8443
--server-insecure-tls
- - name: Reread supervisord configuration EL9
- when:
- - ansible_distribution == 'OracleLinux' or ansible_distribution == 'AlmaLinux'
- - ansible_distribution_major_version == '9'
- command: /usr/local/bin/supervisorctl reread
+ - 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: See what services are running
+ - name: See which service configs changed
debug: var=reread_result.stdout_lines
- - name: Stop pmm-managed before deleting the database EL9
- when:
- - ansible_distribution == 'OracleLinux' or ansible_distribution == 'AlmaLinux'
- - ansible_distribution_major_version == '9'
+ - name: Stop pmm-managed before deleting the database
supervisorctl:
name: pmm-managed
state: stopped
-
- - name: Stop supervisord service for AMI/OVF
- when: ansible_virtualization_type != "docker"
- service: name=supervisord state=stopped enabled=yes
-
- - name: Stop supervisord service for docker
- when: ansible_virtualization_type == "docker"
- shell: supervisorctl shutdown
-
- # PMM-11336 - The previous steps failed to start PostgreSQL using supervisord,
- # so a temporary solution was to start it without supervisord and remove the
- # pmm-managed database/role. However, a complete overhaul of the pipeline is
- # necessary for a permanent fix.
- - name: Stop PostgreSQL database without supervisord
- command: /usr/pgsql-14/bin/pg_ctl stop -D /srv/postgres14
- become: yes
+ become: true
become_user: pmm
- ignore_errors: yes
- when: ansible_virtualization_type != "docker"
-
- - name: Start PostgreSQL database without supervisord
- command: /usr/pgsql-14/bin/pg_ctl start -D /srv/postgres14 -o "-c logging_collector=off"
- become: yes
- become_user: pmm
- ignore_errors: yes
- when: ansible_virtualization_type != "docker"
+ become_method: su
- - name: Remove pmm-managed database EL9
- when:
- - ansible_distribution == 'OracleLinux' or ansible_distribution == 'AlmaLinux'
- - ansible_distribution_major_version == '9'
+ - name: Remove pmm-managed database
postgresql_db:
login_user: postgres
name: pmm-managed
@@ -130,31 +66,44 @@
name: pmm-managed
state: absent
- - name: Stop PostgreSQL database without supervisord
- command: /usr/pgsql-14/bin/pg_ctl stop -D /srv/postgres14
- become: yes
+ - name: Stop supervisord service for docker
+ command: supervisorctl shutdown
+ become: true
become_user: pmm
- ignore_errors: yes
- when: ansible_virtualization_type != "docker"
+ become_method: su
- - name: Cleanup yum cache | Cleanup yum cache
- command: yum clean all
+ - name: Cleanup dnf cache
+ command: dnf clean all
- # "yum clean all" function will only remove cache from configured yum repositories
- # Details: https://bugzilla.redhat.com/show_bug.cgi?id=1357083
- - name: Cleanup yum cache
+ # "yum clean all" function will only remove cache from configured yum repositories
+ # Details: https://bugzilla.redhat.com/show_bug.cgi?id=1357083
+ - name: Cleanup dnf cache
file:
state: absent
- path: /var/cache/yum
+ path: /var/cache/dnf
- - name: Post-build cleanup | Cleanup build logs and data
- file: path={{ item }} state=absent
- with_items:
+ - name: Cleanup build logs and data
+ file:
+ path: "{{ item }}"
+ state: absent
+ loop:
- /srv/logs
- /tmp/RPMS
- - /var/log/yum.log
+ - /var/log/dnf.log
- /var/log/secure
- /var/log/wtmp
+ - /var/log/clickhouse-server
+ - /var/log/nginx
+ - /var/lib/pgsql
+
+ - name: Remove users created by installers
+ user:
+ name: "{{ item }}"
+ state: absent
+ loop:
+ - postgres
+ - clickhouse
+ - nginx
- name: Clean Clickhouse dir
shell: find /srv/clickhouse -mindepth 1 -maxdepth 1 -print0 | xargs -0 rm -rf --
@@ -172,7 +121,7 @@
owner: pmm
group: pmm
mode: 0775
- with_items:
+ loop:
- absent
- directory
@@ -183,3 +132,12 @@
owner: pmm
group: pmm
mode: 0775
+
+ # nginx needs to be able to write to /var/lib/nginx, but it's owned by root.
+ - name: Change ownership of nginx dirs
+ file:
+ path: /var/lib/nginx
+ state: directory
+ group: pmm
+ owner: pmm
+ recurse: yes
diff --git a/build/ansible/pmm/systemd.yml b/build/ansible/pmm/systemd.yml
new file mode 100644
index 0000000000..8d16d20a2f
--- /dev/null
+++ b/build/ansible/pmm/systemd.yml
@@ -0,0 +1,43 @@
+---
+# This playbook contains tasks executed during PMM Server update in non-docker environments.
+# TODO: refactor from supervisord to systemd if necessary.
+# NOTE: it's currently unused, just a placeholder for future use.
+- hosts: all
+ become: true
+ remote_user: root
+ gather_facts: true
+
+ # TODO: replace supervisord.service with pmm.service
+ tasks:
+ # Note: forking type must be set to 'simple'
+ - name: Configure supervisord
+ copy:
+ src: supervisord.service
+ dest: /usr/lib/systemd/system/supervisord.service
+ mode: 0644
+
+ # Start the services
+ - name: Enable supervisord service to persist between reboots
+ systemd:
+ name: supervisord
+ enabled: yes
+
+ - name: Start supervisord service for AMI/OVF
+ systemd:
+ name: supervisord
+ state: started # supervisord may already be running
+ daemon_reload: yes
+
+ - name: Enable crond service
+ service:
+ name: crond
+ state: started
+ enabled: yes
+
+ # https://jira.percona.com/browse/PMM-9298
+ - name: Copy rezise-xfs file for lvm
+ copy:
+ src: resize-xfs-lvm
+ dest: /var/lib/cloud/scripts/per-boot/resize-xfs
+ mode: 0755
+ force: true
diff --git a/update/ansible/playbook/tasks/roles/clickhouse/defaults/main.yml b/build/ansible/roles/clickhouse/defaults/main.yml
similarity index 100%
rename from update/ansible/playbook/tasks/roles/clickhouse/defaults/main.yml
rename to build/ansible/roles/clickhouse/defaults/main.yml
diff --git a/update/ansible/playbook/tasks/roles/clickhouse/files/config.xml b/build/ansible/roles/clickhouse/files/config.xml
similarity index 99%
rename from update/ansible/playbook/tasks/roles/clickhouse/files/config.xml
rename to build/ansible/roles/clickhouse/files/config.xml
index 0ccb6ae4bf..20a08592d3 100644
--- a/update/ansible/playbook/tasks/roles/clickhouse/files/config.xml
+++ b/build/ansible/roles/clickhouse/files/config.xml
@@ -23,7 +23,10 @@
-->
information
1
- /srv/logs/clickhouse-server.log
+