|
6 | 6 | - vars.yml |
7 | 7 |
|
8 | 8 | tasks: |
9 | | -# Add Percona repository on Debian/Ubuntu |
| 9 | + #Add Percona repository on Debian/Ubuntu |
10 | 10 | - name: Add Percona repository on Debian/Ubuntu |
11 | 11 | block: |
12 | | - - name: Install curl if not already installed |
| 12 | + - name: Install required packages for Percona repository |
13 | 13 | ansible.builtin.package: |
14 | | - name: curl |
| 14 | + name: |
| 15 | + - curl |
| 16 | + - gnupg2 |
| 17 | + - lsb-release |
15 | 18 | state: present |
16 | 19 |
|
17 | 20 | - name: Download Percona repository package |
|
21 | 24 |
|
22 | 25 | - name: Install Percona repository package |
23 | 26 | 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 |
25 | 28 | args: |
26 | 29 | executable: /bin/bash |
27 | 30 |
|
|
73 | 76 | become_user: postgres |
74 | 77 |
|
75 | 78 | # 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 |
77 | 80 | ansible.builtin.lineinfile: |
78 | 81 | path: "{{ pg_hba_conf_path }}" |
79 | | - line: "local all {{ pmm_postgresql_user }} md5" |
| 82 | + line: "host all pmm 0.0.0.0/0 md5" |
80 | 83 | 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 |
82 | 92 |
|
83 | 93 | # Configure shared_preload_libraries in postgresql.conf |
84 | 94 | - name: Configure shared_preload_libraries |
|
91 | 101 |
|
92 | 102 | # Install PostgreSQL extensions |
93 | 103 | - 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 }};' |
95 | 106 | with_items: "{{ pg_extensions }}" |
96 | 107 | become_user: postgres |
97 | 108 |
|
98 | 109 | # Configure PMM Client to connect to PMM Server |
99 | 110 | - 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 |
102 | 116 | register: pmm_config_output |
103 | 117 | changed_when: false |
104 | 118 |
|
105 | 119 | # Add PostgreSQL service to PMM |
106 | 120 | - 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 |
109 | 133 | register: pmm_add_service_output |
110 | 134 | changed_when: false |
111 | 135 |
|
|
0 commit comments