Skip to content

Commit 557423e

Browse files
authored
Ensure RemoveIPC is disabled to prevent shared memory segment issues (#1200)
1 parent 3492a49 commit 557423e

File tree

6 files changed

+47
-10
lines changed

6 files changed

+47
-10
lines changed

automation/roles/etcd/tasks/main.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@
6565
name: etcd
6666
shell: /usr/sbin/nologin
6767
home: "{{ etcd_data_dir }}"
68+
system: true
6869
tags: etcd, etcd_conf
6970

7071
- name: Create etcd conf directory

automation/roles/haproxy/tasks/main.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@
6868
comment: "HAProxy user"
6969
group: haproxy
7070
shell: /usr/sbin/nologin
71+
system: true
7172
tags: haproxy, load_balancing
7273

7374
- name: Create directories

automation/roles/pgbackrest/tasks/ssh_keys.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
ansible.builtin.user:
3030
name: "{{ pgbackrest_repo_user }}"
3131
state: present
32+
system: true
3233
when: "'pgbackrest' in group_names"
3334

3435
- name: ssh_keys | Ensure ssh key are created for "{{ pgbackrest_repo_user }}" user on pgbackrest server
@@ -39,6 +40,13 @@
3940
ssh_key_file: .ssh/id_rsa
4041
when: "'pgbackrest' in group_names"
4142

43+
- name: Ensure "postgres" exists on database servers
44+
ansible.builtin.user:
45+
name: "postgres"
46+
state: present
47+
system: true
48+
when: "'postgres_cluster' in group_names"
49+
4250
- name: ssh_keys | Ensure ssh key are created for "postgres" user on database servers
4351
ansible.builtin.user:
4452
name: "postgres"

automation/roles/pre_checks/tasks/main.yml

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@
33
ansible.builtin.fail:
44
msg: "Ansible version must be {{ minimal_ansible_version }} or higher"
55
delegate_to: localhost
6-
when:
7-
- ansible_version.full is version(minimal_ansible_version, '<')
6+
when: ansible_version.full is version(minimal_ansible_version, '<')
87

98
- name: Checking Linux distribution
109
ansible.builtin.fail:
@@ -16,6 +15,10 @@
1615
msg: "{{ ansible_distribution_version }} of {{ ansible_distribution }} is not supported"
1716
when: ansible_distribution_version is version_compare(os_minimum_versions[ansible_distribution], '<')
1817

18+
- name: Perform pre-checks for system
19+
ansible.builtin.import_tasks: system.yml
20+
when: inventory_hostname in groups['postgres_cluster']
21+
1922
- name: Perform pre-checks for pgbouncer
2023
ansible.builtin.import_tasks: pgbouncer.yml
2124
when:
@@ -25,13 +28,11 @@
2528

2629
- name: Perform pre-checks for patroni
2730
ansible.builtin.import_tasks: patroni.yml
28-
when:
29-
- inventory_hostname in groups['postgres_cluster']
31+
when: inventory_hostname in groups['postgres_cluster']
3032

3133
- name: Perform pre-checks for huge_pages
3234
ansible.builtin.import_tasks: huge_pages.yml
33-
when:
34-
- inventory_hostname in groups['postgres_cluster']
35+
when: inventory_hostname in groups['postgres_cluster']
3536

3637
- name: Perform pre-checks for pgbackrest
3738
ansible.builtin.import_tasks: pgbackrest.yml
@@ -47,10 +48,10 @@
4748
- wal_g_install | bool
4849
- inventory_hostname in groups['postgres_cluster']
4950

50-
- name: Generate passwords
51-
ansible.builtin.import_tasks: passwords.yml
52-
when: inventory_hostname in groups['postgres_cluster']
53-
5451
- name: Perform pre-checks for extensions
5552
ansible.builtin.import_tasks: extensions.yml
5653
when: inventory_hostname == groups['master'][0]
54+
55+
- name: Generate passwords
56+
ansible.builtin.import_tasks: passwords.yml
57+
when: inventory_hostname in groups['postgres_cluster']
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
---
2+
# https://www.postgresql.org/docs/current/kernel-resources.html#SYSTEMD-REMOVEIPC
3+
#
4+
# Configure systemd RemoveIPC=no to prevent errors like:
5+
# WARNING: could not remove shared memory segment "/PostgreSQL.1450751626": No such file or directory
6+
# FATAL: could not open shared memory segment "/PostgreSQL.3317458760": No such file or directory
7+
8+
- name: Ensure RemoveIPC is disabled (RemoveIPC=no in logind.conf)
9+
community.general.ini_file:
10+
path: /etc/systemd/logind.conf
11+
section: Login
12+
option: RemoveIPC
13+
value: "no"
14+
create: true
15+
backup: true
16+
register: removeipc_result
17+
18+
- name: Restart systemd-logind service
19+
ansible.builtin.systemd:
20+
name: systemd-logind
21+
masked: false
22+
state: restarted
23+
when:
24+
- removeipc_result.changed
25+
- ansible_service_mgr == "systemd"

automation/roles/ssh_keys/tasks/main.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
name: "{{ ssh_key_user }}"
3434
shell: /bin/bash
3535
state: present
36+
system: true
3637

3738
- name: Create a 2048-bit SSH key for user "{{ ssh_key_user }}" in ~/.ssh/id_rsa (if not already exist)
3839
ansible.builtin.user:

0 commit comments

Comments
 (0)