Commit 6aecc539 authored by viscapi's avatar viscapi
Browse files

Merge branch 'postgresql-systemd-improvement' into 'master'

Postgresql systemd improvement

See merge request !1
parents c42647cb a5d16129
---
- name: Set PGDATA environment variable on CentOS 7
lineinfile:
path: /usr/lib/systemd/system/postgresql.service
regexp: '^Environment=PGDATA='
line: 'Environment=PGDATA={{path_to_icat}}'
when: (ansible_facts['distribution'] == "CentOS" and ansible_facts['distribution_major_version'] == "7" and use_distribution_postgresql)
- name: Set PGDATA environment variable on CentOS 7
lineinfile:
path: /usr/lib/systemd/system/postgresql-{{ external_postgresql_version }}.service
regexp: '^Environment=PGDATA='
line: 'Environment=PGDATA={{path_to_icat}}'
when: (ansible_facts['distribution'] == "CentOS" and ansible_facts['distribution_major_version'] == "7" and not use_distribution_postgresql)
- name: Set PGDATA environment variable on CentOS 8
lineinfile:
path: /usr/lib/systemd/system/postgresql.service
regexp: '^Environment=PGDATA='
line: 'Environment=PGDATA={{path_to_icat}}'
when: (ansible_facts['distribution'] == "CentOS" and ansible_facts['distribution_major_version'] == "8" and use_distribution_postgresql)
- name: Set PGDATA environment variable on CentOS 8
lineinfile:
path: /usr/lib/systemd/system/postgresql-{{ external_postgresql_version }}.service
regexp: '^Environment=PGDATA='
line: 'Environment=PGDATA={{path_to_icat}}'
when: (ansible_facts['distribution'] == "CentOS" and ansible_facts['distribution_major_version'] == "8" and not use_distribution_postgresql)
# Dynamically set some variables commonly used by this task group.
- name: Setting facts for systemd operations.
vars:
external_postgres_suffix: "-{{ external_postgresql_version }}"
# Suffix will be '-version', e.g. '-13' for postgresql v13.x.x, or '' (nothing) if we do use the version distributed by the standard repository.
suffix: "{{ ( use_distribution_postgresql == false ) | ternary(external_postgres_suffix, '') }}"
set_fact:
postgres_unit_file_name: "postgresql{{ suffix }}.service"
# This task will place an 'override' for the systemd unit file distributed by postgresql.
# Modifying the original unit file is not recomended as it is replaced with each update of postgresql.
#
# Its current purpose is to define the path to the data directory where the database's actual data will be on the system.
# cf. The template file.
- name: "Define the {{ postgres_unit_file_name }} override file."
template:
src: templates/postgresql.service.j2
dest: "/etc/systemd/system/{{ postgres_unit_file_name }}"
owner: root
group: wheel
mode: '0644'
when:
- path_to_icat is defined
- path_to_icat != None
- path_to_icat | length > 0
- name: Start postgresql service on CentOS 7
systemd:
......@@ -36,7 +34,7 @@
enabled: yes
when: (ansible_facts['distribution'] == "CentOS" and ansible_facts['distribution_major_version'] == "7" and use_distribution_postgresql)
- name: Start postgresql-{{ postgresql_version }} service on CentOS 7
- name: Start postgresql-{{ external_postgresql_version }} service on CentOS 7
systemd:
name: postgresql-{{ external_postgresql_version }}
state: started
......
.include /usr/lib/systemd/system/{{ postgres_unit_file_name }}
[Service]
Environment=PGDATA={{ path_to_icat }}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment