Skip to content

Commit 366e190

Browse files
committed
Add RHEL/CentOS 8 compatibility.
* Added "os_specific_packages" variable with a list of requarements for specific RHEL Linux versions. * Added chronyd (ntp) service. In RHEL Linux 8, the ntp package is no longer supported and it is implemented by the chronyd (a daemon that runs in user-space) which is provided in the chrony package. * Added the glibc-langpack installation instead of generating a locales (for RHEL 8 only). Variable: "glibc_langpack" in the RedHat.yml inventory file. * Added disable postgresql module for RHEL 8. The version of PostgreSQL available on CentOS 8 / RHEL 8 officially maintained modular repository is 10 and 9.6. We’ll add PostgreSQL Yum Repository (by default) which hosts all recent releases. * Install pgbouncer package with the "--disablerepo AppStream" parameter. Since the AppStream repository (for today) does not have the required version of python-psycopg2. For RHEL 8 only. Fixed dpendency roblem: package pgbouncer-1.12.0-1.rhel8.x86_64 requires python-psycopg2, but none of the providers can be installed. Other: * Fix parameters of the "package" module for HAProxy on RHEL Linux 8. * Fix ansible-role-firewall: added a Boolean filter for disable-other-firewalls task. Tested on CentOS Linux release 8.0.1905
1 parent a7bd999 commit 366e190

File tree

10 files changed

+142
-24
lines changed

10 files changed

+142
-24
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ RedHat and Debian based distros (x86_64)
6969
- Ubuntu: 16.04
7070
- Debian: 8
7171

72-
:white_check_mark: tested, works fine: `Debian 9/10, Ubuntu 18.04, CentOS 7.6`
72+
:white_check_mark: tested, works fine: `Debian 9/10, Ubuntu 18.04, CentOS 7.6/7.7/8.0`
7373

7474
###### PostgreSQL versions:
7575
all supported PostgreSQL versions

roles/ansible-role-firewall/tasks/main.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -64,4 +64,4 @@
6464
enabled: "{{ firewall_enabled_at_boot }}"
6565

6666
- import_tasks: disable-other-firewalls.yml
67-
when: firewall_disable_firewalld == "true" or firewall_disable_ufw == "true"
67+
when: firewall_disable_firewalld|bool or firewall_disable_ufw|bool

tasks/haproxy.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@
4949
# RedHat os family version 8 (and higher)
5050
- name: haproxy | install HAProxy 1.8 package
5151
package:
52-
name: "haproxy=1.8.*"
53-
state: haproxy
52+
name: haproxy
53+
state: present
5454
when: ansible_distribution_major_version is version('8', '>=')
5555
environment: '{{ proxy_env | default({}) }}'
5656
when: ansible_os_family == "RedHat" and installation_method == "repo" and haproxy_installation_method == "rpm"

tasks/locales.yml

+10-1
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,13 @@
1515
command: localedef -c -i {{ item.language_country }} -f {{ item.encoding }} {{ item.language_country }}.{{ item.encoding }}
1616
changed_when: false
1717
loop: "{{ locales | flatten(1) }}"
18-
when: ansible_os_family == "RedHat"
18+
when: ansible_os_family == "RedHat" and ansible_distribution_major_version != '8'
19+
20+
# RHEL 8
21+
- name: locales | install glibc-langpack
22+
dnf:
23+
name: "{{ item }}"
24+
loop: "{{ glibc_langpack }}"
25+
environment: '{{ proxy_env | default({}) }}'
26+
when: ansible_os_family == "RedHat" and ansible_distribution_major_version >= '8'
27+

tasks/ntp.yml

+32-3
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,59 @@
11
---
22

3+
# NTPd: Install and Configure
34
- name: ntp | install package
45
package:
56
name: ntp
67
state: present
78
environment: '{{ proxy_env | default({}) }}'
9+
when: ansible_os_family == "Debian" or (ansible_os_family == "RedHat" and ansible_distribution_major_version == '7')
810
tags: [ ntp_install, ntp ]
911

1012
- name: ntp | copy the ntp.conf template file
1113
template:
1214
src: ntp.conf.j2
1315
dest: /etc/ntp.conf
16+
when: ansible_os_family == "Debian" or (ansible_os_family == "RedHat" and ansible_distribution_major_version == '7')
1417
tags: [ ntp_conf, ntp ]
1518

1619
# Debian
17-
- name: ntp | restart systemd service
20+
- name: ntp | restart ntp service
1821
systemd:
1922
name: ntp
2023
enabled: yes
2124
state: restarted
2225
when: ansible_os_family == "Debian"
26+
tags: ntp
2327

2428
# RedHat
25-
- name: ntp | restart systemd service
29+
- name: ntp | restart ntpd service
2630
systemd:
2731
name: ntpd
2832
enabled: yes
2933
state: restarted
30-
when: ansible_os_family == "RedHat"
34+
when: ansible_os_family == "RedHat" and ansible_distribution_major_version == '7'
35+
tags: ntp
36+
37+
# Chrony: Install and Configure (RHEL 8)
38+
- block:
39+
- name: ntp | install chrony package
40+
package:
41+
name: chrony
42+
state: present
43+
environment: '{{ proxy_env | default({}) }}'
44+
tags: ntp_install
45+
46+
- name: ntp | copy the chrony.conf template file
47+
template:
48+
src: chrony.conf.j2
49+
dest: /etc/chrony.conf
50+
tags: ntp_conf
51+
52+
- name: ntp | restart chrony service
53+
systemd:
54+
name: chronyd
55+
enabled: yes
56+
state: restarted
57+
when: ansible_os_family == "RedHat" and ansible_distribution_major_version >= '8'
58+
tags: ntp
59+

tasks/packages.yml

+15-3
Original file line numberDiff line numberDiff line change
@@ -37,29 +37,41 @@
3737

3838
# PostgreSQL prepare for install (for Debian based only)
3939
- block:
40-
- name: Install | ensure postgresql database-cluster manager package
40+
- name: Install | PostgreSQL | ensure postgresql database-cluster manager package
4141
package:
4242
name: postgresql-common
4343
state: present
4444
environment: '{{ proxy_env | default({}) }}'
4545

46-
- name: disable initializing of a default postgresql cluster
46+
- name: Install | PostgreSQL | disable initializing of a default postgresql cluster
4747
replace:
4848
path: /etc/postgresql-common/createcluster.conf
4949
replace: create_main_cluster = false
5050
regexp: ^#?create_main_cluster.*$
5151

52-
- name: disable log rotation with logrotate for postgresql (use logging_collector)
52+
- name: Install | PostgreSQL | disable log rotation with logrotate for postgresql (use logging_collector)
5353
file:
5454
dest: /etc/logrotate.d/postgresql-common
5555
state: absent
5656
when: installation_method == "repo" and ansible_os_family == "Debian"
5757
tags: install_postgres
5858

59+
# PostgreSQL prepare for install (for RHEL 8)
60+
- block:
61+
- name: Install | PostgreSQL | disable postgresql module
62+
shell: 'dnf -y module disable postgresql && dnf clean all'
63+
args:
64+
warn: false
65+
environment: '{{ proxy_env | default({}) }}'
66+
when: installation_method == "repo" and (proxy_env is defined and proxy_env | length > 0) and (ansible_os_family == "RedHat" and ansible_distribution_major_version >= '8')
67+
ignore_errors: yes
68+
tags: install_postgres
69+
5970
# Install PostgreSQL from repository
6071
- name: Install | PostgreSQL packages
6172
package:
6273
name: "{{ item }}"
74+
update_cache: yes
6375
loop: "{{ postgresql_packages }}"
6476
environment: '{{ proxy_env | default({}) }}'
6577
when: installation_method == "repo" and postgresql_exists != "true"

tasks/pgbouncer.yml

+10
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,16 @@
44
package:
55
name: pgbouncer
66
environment: '{{ proxy_env | default({}) }}'
7+
when: ansible_os_family == "Debian" or (ansible_os_family == "RedHat" and ansible_distribution_major_version == '7')
8+
tags: [ pgbouncer_install, pgbouncer ]
9+
10+
# RHEL 8
11+
- name: PgBouncer | install package
12+
dnf:
13+
name: pgbouncer
14+
disablerepo: AppStream
15+
environment: '{{ proxy_env | default({}) }}'
16+
when: ansible_os_family == "RedHat" and ansible_distribution_major_version >= '8'
717
tags: [ pgbouncer_install, pgbouncer ]
818

919
- name: PgBouncer | ensure config directory "{{ pgbouncer_conf_dir }}" exist

templates/chrony.conf.j2

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# Use public servers from the pool.ntp.org project.
2+
# Please consider joining the pool (http://www.pool.ntp.org/join.html).
3+
{% if ntp_servers is defined and ntp_servers | length > 0 %}
4+
{% for item in ntp_servers %}
5+
server {{ item }} iburst
6+
{% endfor %}
7+
{% endif %}
8+
9+
# Record the rate at which the system clock gains/losses time.
10+
driftfile /var/lib/chrony/drift
11+
12+
# Allow the system clock to be stepped in the first three updates
13+
# if its offset is larger than 1 second.
14+
makestep 1.0 3
15+
16+
# Enable kernel synchronization of the real-time clock (RTC).
17+
rtcsync
18+
19+
# Enable hardware timestamping on all interfaces that support it.
20+
#hwtimestamp *
21+
22+
# Increase the minimum number of selectable sources required to adjust
23+
# the system clock.
24+
#minsources 2
25+
26+
# Allow NTP client access from local network.
27+
#allow 192.168.0.0/16
28+
29+
# Serve time even if not synchronized to a time source.
30+
#local stratum 10
31+
32+
# Specify file containing keys for NTP authentication.
33+
keyfile /etc/chrony.keys
34+
35+
# Get TAI-UTC offset and leap seconds from the system tz database.
36+
leapsectz right/UTC
37+
38+
# Specify directory for log files.
39+
logdir /var/log/chrony
40+
41+
# Select which information is logged.
42+
#log measurements statistics tracking

vars/RedHat.yml

+26-12
Original file line numberDiff line numberDiff line change
@@ -24,19 +24,26 @@ install_epel_repo: 'true' # or 'false' (installed from the package "epel-release
2424
install_postgresql_repo: 'true' # or 'false' (installed from the package "pgdg-redhat-repo-latest.noarch.rpm" tasks/add-repository.yml)
2525

2626
# Packages (for yum repo)
27+
os_specific_packages:
28+
RedHat-7:
29+
- python
30+
- python-devel
31+
- python-psycopg2
32+
- python-setuptools
33+
- libselinux-python
34+
- libsemanage-python
35+
- policycoreutils-python
36+
RedHat-8:
37+
- python3-libselinux
38+
- python3-libsemanage
39+
- python3-policycoreutils
2740
system_packages:
28-
- python
29-
- python-devel
30-
- python-psycopg2
31-
- python-setuptools
32-
- libselinux-python
33-
- libsemanage-python
34-
- policycoreutils-python
35-
- python36
36-
- python36-devel
37-
- python36-psycopg2
38-
- python36-setuptools
39-
- python36-pip
41+
- python3
42+
- python3-devel
43+
- python3-psycopg2
44+
- python3-setuptools
45+
- python3-pip
46+
- "{{ os_specific_packages[ansible_os_family ~ '-' ~ ansible_distribution_major_version] }}"
4047
- curl
4148
- less
4249
- sudo
@@ -46,6 +53,13 @@ system_packages:
4653
- iptables
4754
- acl
4855

56+
# The glibc-langpack package includes the basic information required to support the language in your applications.
57+
## for RHEL version 8 (only)
58+
glibc_langpack:
59+
- "glibc-langpack-en"
60+
- "glibc-langpack-ru" # optional
61+
# - "glibc-langpack-de"
62+
4963
postgresql_packages:
5064
- postgresql{{ postgresql_version_terse }}
5165
- postgresql{{ postgresql_version_terse }}-server

vars/main.yml

+3-1
Original file line numberDiff line numberDiff line change
@@ -204,9 +204,11 @@ ntp_servers: []
204204
timezone: []
205205
#timezone: "Europe/Moscow"
206206

207+
# Generate locale
208+
## (except RHEL>=8,use glibc-langpack)
207209
locales:
208210
- { language_country: "en_US", encoding: "UTF-8" }
209-
- { language_country: "ru_RU", encoding: "UTF-8" }
211+
- { language_country: "ru_RU", encoding: "UTF-8" } # optional
210212
# - { language_country: "", encoding: "" }
211213

212214

0 commit comments

Comments
 (0)