Skip to content

Commit 64251c7

Browse files
committed
[FIX] bugs fixed
1 parent cb6f38b commit 64251c7

File tree

1 file changed

+36
-12
lines changed

1 file changed

+36
-12
lines changed

Ansible/percona-pmm/pmm_postgresql.yml

Lines changed: 36 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,15 @@
66
- vars.yml
77

88
tasks:
9-
# Add Percona repository on Debian/Ubuntu
9+
#Add Percona repository on Debian/Ubuntu
1010
- name: Add Percona repository on Debian/Ubuntu
1111
block:
12-
- name: Install curl if not already installed
12+
- name: Install required packages for Percona repository
1313
ansible.builtin.package:
14-
name: curl
14+
name:
15+
- curl
16+
- gnupg2
17+
- lsb-release
1518
state: present
1619

1720
- name: Download Percona repository package
@@ -21,7 +24,7 @@
2124

2225
- name: Install Percona repository package
2326
ansible.builtin.shell: |
24-
apt install -y gnupg2 lsb-release /tmp/percona-release_latest.generic_all.deb
27+
apt install -y /tmp/percona-release_latest.generic_all.deb
2528
args:
2629
executable: /bin/bash
2730

@@ -73,12 +76,19 @@
7376
become_user: postgres
7477

7578
# Allow PMM user in pg_hba.conf
76-
- name: Allow PMM user in pg_hba.conf
79+
- name: Allow PMM user in pg_hba.conf for IPv4
7780
ansible.builtin.lineinfile:
7881
path: "{{ pg_hba_conf_path }}"
79-
line: "local all {{ pmm_postgresql_user }} md5"
82+
line: "host all pmm 0.0.0.0/0 md5"
8083
state: present
81-
notify: Reload PostgreSQL
84+
notify: Restart PostgreSQL
85+
86+
- name: Allow PMM user in pg_hba.conf for IPv6
87+
ansible.builtin.lineinfile:
88+
path: "{{ pg_hba_conf_path }}"
89+
line: "host all pmm ::/0 md5"
90+
state: present
91+
notify: Restart PostgreSQL
8292

8393
# Configure shared_preload_libraries in postgresql.conf
8494
- name: Configure shared_preload_libraries
@@ -91,21 +101,35 @@
91101

92102
# Install PostgreSQL extensions
93103
- name: Install PostgreSQL extensions
94-
ansible.builtin.shell: "psql -U {{ postgresql_admin_user }} -d postgres -c 'CREATE EXTENSION IF NOT EXISTS {{ item }};'"
104+
ansible.builtin.shell: >
105+
psql -U {{ postgresql_admin_user }} -d postgres -c 'CREATE EXTENSION IF NOT EXISTS {{ item }};'
95106
with_items: "{{ pg_extensions }}"
96107
become_user: postgres
97108

98109
# Configure PMM Client to connect to PMM Server
99110
- name: Register PMM Client with PMM Server
100-
ansible.builtin.command:
101-
cmd: "pmm-admin config --server-insecure-tls --server-url=https://{{ pmm_server_username }}:{{ admin_password }}@{{ pmm_server_address }} {{ inventory_hostname }} --force"
111+
ansible.builtin.command: >
112+
pmm-admin config
113+
--server-insecure-tls
114+
--server-url=https://{{ pmm_server_username }}:{{ admin_password }}@{{ pmm_server_address }}
115+
{{ inventory_hostname }} --force
102116
register: pmm_config_output
103117
changed_when: false
104118

105119
# Add PostgreSQL service to PMM
106120
- name: Add PostgreSQL to PMM
107-
ansible.builtin.command:
108-
cmd: "pmm-admin add postgresql --username={{ pmm_postgresql_user }} --password={{ pmm_postgresql_password }} --service-name={{ inventory_hostname }}-postgresql --host={{ ansible_host }} --port=5432"
121+
ansible.builtin.command: >
122+
pmm-admin add postgresql
123+
--username={{ pmm_postgresql_user }}
124+
--password={{ pmm_postgresql_password }}
125+
--server-url=https://{{ pmm_server_username }}:{{ admin_password }}@{{ pmm_server_address }}
126+
--server-insecure-tls
127+
--service-name={{ inventory_hostname }}-postgresql
128+
--host={{ ansible_host }}
129+
--port=5432
130+
--force
131+
args:
132+
executable: /bin/bash
109133
register: pmm_add_service_output
110134
changed_when: false
111135

0 commit comments

Comments
 (0)