feat: add test for Rocky Linux 8 #1
@ -71,7 +71,7 @@ local PipelineDeployment(scenario='centos7') = {
|
|||||||
'linting',
|
'linting',
|
||||||
],
|
],
|
||||||
trigger: {
|
trigger: {
|
||||||
ref: ['refs/heads/master', 'refs/tags/**'],
|
ref: ['refs/heads/master', 'refs/tags/**', 'refs/pull/**'],
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -116,6 +116,7 @@ local PipelineDocumentation = {
|
|||||||
},
|
},
|
||||||
depends_on: [
|
depends_on: [
|
||||||
'testing-centos7',
|
'testing-centos7',
|
||||||
|
'testing-rocky8',
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -154,6 +155,7 @@ local PipelineNotification = {
|
|||||||
[
|
[
|
||||||
PipelineLinting,
|
PipelineLinting,
|
||||||
PipelineDeployment(scenario='centos7'),
|
PipelineDeployment(scenario='centos7'),
|
||||||
|
PipelineDeployment(scenario='rocky8'),
|
||||||
PipelineDocumentation,
|
PipelineDocumentation,
|
||||||
PipelineNotification,
|
PipelineNotification,
|
||||||
]
|
]
|
||||||
|
37
.drone.yml
37
.drone.yml
@ -62,6 +62,40 @@ trigger:
|
|||||||
ref:
|
ref:
|
||||||
- refs/heads/master
|
- refs/heads/master
|
||||||
- refs/tags/**
|
- refs/tags/**
|
||||||
|
- refs/pull/**
|
||||||
|
|
||||||
|
depends_on:
|
||||||
|
- linting
|
||||||
|
|
||||||
|
---
|
||||||
|
kind: pipeline
|
||||||
|
name: testing-rocky8
|
||||||
|
|
||||||
|
platform:
|
||||||
|
os: linux
|
||||||
|
arch: amd64
|
||||||
|
|
||||||
|
concurrency:
|
||||||
|
limit: 1
|
||||||
|
|
||||||
|
workspace:
|
||||||
|
base: /drone/src
|
||||||
|
path: ${DRONE_REPO_NAME}
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: ansible-molecule
|
||||||
|
image: thegeeklab/molecule:3
|
||||||
|
commands:
|
||||||
|
- molecule test -s rocky8
|
||||||
|
environment:
|
||||||
|
HCLOUD_TOKEN:
|
||||||
|
from_secret: hcloud_token
|
||||||
|
|
||||||
|
trigger:
|
||||||
|
ref:
|
||||||
|
- refs/heads/master
|
||||||
|
- refs/tags/**
|
||||||
|
- refs/pull/**
|
||||||
|
|
||||||
depends_on:
|
depends_on:
|
||||||
- linting
|
- linting
|
||||||
@ -108,6 +142,7 @@ trigger:
|
|||||||
|
|
||||||
depends_on:
|
depends_on:
|
||||||
- testing-centos7
|
- testing-centos7
|
||||||
|
- testing-rocky8
|
||||||
|
|
||||||
---
|
---
|
||||||
kind: pipeline
|
kind: pipeline
|
||||||
@ -147,6 +182,6 @@ depends_on:
|
|||||||
|
|
||||||
---
|
---
|
||||||
kind: signature
|
kind: signature
|
||||||
hmac: 9c670d53b462557f2945be4d94c2b0328bd971e10e43ce61ca106ca9669bb167
|
hmac: 916e22d58f38ffdeb4b10459c2ebdef15e69b4a3704bb1d2679e0b0629865981
|
||||||
|
|
||||||
...
|
...
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
---
|
---
|
||||||
postgres_repository_enabled: False
|
postgres_repository_enabled: False
|
||||||
postgres_version: 12
|
postgres_version: 14
|
||||||
postgres_repository_filename: "Postgresql-{{ postgres_version | regex_replace('\\.') }}"
|
postgres_repository_filename: "Postgresql-{{ postgres_version | regex_replace('\\.') }}"
|
||||||
postgres_user: postgres
|
postgres_user: postgres
|
||||||
postgres_group: postgres
|
postgres_group: postgres
|
||||||
@ -20,7 +20,7 @@ postgres_connection_addresses:
|
|||||||
postgres_socket_directories:
|
postgres_socket_directories:
|
||||||
- /var/run/postgresql
|
- /var/run/postgresql
|
||||||
|
|
||||||
postgres_password_encryption: md5
|
postgres_password_encryption: scram-sha-256
|
||||||
|
|
||||||
postgres_tls_enabled: False
|
postgres_tls_enabled: False
|
||||||
postgres_tls_cert_filename: "mycert.pem"
|
postgres_tls_cert_filename: "mycert.pem"
|
||||||
@ -81,13 +81,13 @@ postgres_hba_entries:
|
|||||||
users:
|
users:
|
||||||
- all
|
- all
|
||||||
address: "127.0.0.1/32"
|
address: "127.0.0.1/32"
|
||||||
auth_method: md5
|
auth_method: "{{ postgres_password_encryption }}"
|
||||||
- contype: host
|
- contype: host
|
||||||
databases:
|
databases:
|
||||||
- all
|
- all
|
||||||
users:
|
users:
|
||||||
- all
|
- all
|
||||||
address: "::1/128"
|
address: "::1/128"
|
||||||
auth_method: md5
|
auth_method: "{{ postgres_password_encryption }}"
|
||||||
|
|
||||||
postgres_hba_entries_extra: []
|
postgres_hba_entries_extra: []
|
||||||
|
@ -8,16 +8,21 @@ testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner(
|
|||||||
|
|
||||||
|
|
||||||
def test_postgres_is_installed(host):
|
def test_postgres_is_installed(host):
|
||||||
postgres = host.package("postgresql12-server")
|
postgres = host.package("postgresql14-server")
|
||||||
assert postgres.is_installed
|
assert postgres.is_installed
|
||||||
|
|
||||||
|
|
||||||
def test_postgres_running_and_enabled(host):
|
def test_postgres_running_and_enabled(host):
|
||||||
postgres = host.service("postgresql-12")
|
postgres = host.service("postgresql-14")
|
||||||
assert postgres.is_running
|
assert postgres.is_running
|
||||||
assert postgres.is_enabled
|
assert postgres.is_enabled
|
||||||
|
|
||||||
|
|
||||||
|
def test_postgres_auth(host):
|
||||||
|
login = host.run("PGPASSWORD=secure psql -U pgdemo -h localhost -c 'select 1' -q demo")
|
||||||
|
assert login.succeeded
|
||||||
|
|
||||||
|
|
||||||
def test_postgres_socket(host):
|
def test_postgres_socket(host):
|
||||||
# Verify the socket is listening for HTTP traffic
|
# Verify the socket is listening for HTTP traffic
|
||||||
assert host.socket("tcp://127.0.0.1:5432").is_listening
|
assert host.socket("tcp://127.0.0.1:5432").is_listening
|
||||||
|
@ -1 +1 @@
|
|||||||
centos7
|
rocky8
|
15
molecule/rocky8/converge.yml
Normal file
15
molecule/rocky8/converge.yml
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
---
|
||||||
|
- name: Converge
|
||||||
|
hosts: all
|
||||||
|
vars:
|
||||||
|
postgres_repository_enabled: True
|
||||||
|
postgres_users:
|
||||||
|
- name: "pgdemo"
|
||||||
|
password: "secure"
|
||||||
|
priv: ALL
|
||||||
|
db: "demo"
|
||||||
|
postgres_dbs:
|
||||||
|
- name: demo
|
||||||
|
|
||||||
|
roles:
|
||||||
|
- role: xoxys.postgres
|
120
molecule/rocky8/create.yml
Normal file
120
molecule/rocky8/create.yml
Normal file
@ -0,0 +1,120 @@
|
|||||||
|
---
|
||||||
|
- name: Create
|
||||||
|
hosts: localhost
|
||||||
|
connection: local
|
||||||
|
gather_facts: false
|
||||||
|
no_log: "{{ molecule_no_log }}"
|
||||||
|
vars:
|
||||||
|
ssh_port: 22
|
||||||
|
ssh_user: root
|
||||||
|
ssh_path: "{{ lookup('env', 'MOLECULE_EPHEMERAL_DIRECTORY') }}/ssh_key"
|
||||||
|
tasks:
|
||||||
|
- name: Create SSH key
|
||||||
|
user:
|
||||||
|
name: "{{ lookup('env', 'USER') }}"
|
||||||
|
generate_ssh_key: true
|
||||||
|
ssh_key_file: "{{ ssh_path }}"
|
||||||
|
force: true
|
||||||
|
register: generated_ssh_key
|
||||||
|
|
||||||
|
- name: Register the SSH key name
|
||||||
|
set_fact:
|
||||||
|
ssh_key_name: "molecule-generated-{{ 12345 | random | to_uuid }}"
|
||||||
|
|
||||||
|
- name: Register SSH key for test instance(s)
|
||||||
|
hcloud_ssh_key:
|
||||||
|
name: "{{ ssh_key_name }}"
|
||||||
|
public_key: "{{ generated_ssh_key.ssh_public_key }}"
|
||||||
|
state: present
|
||||||
|
|
||||||
|
- name: Create molecule instance(s)
|
||||||
|
hcloud_server:
|
||||||
|
name: "{{ item.name }}"
|
||||||
|
server_type: "{{ item.server_type }}"
|
||||||
|
ssh_keys:
|
||||||
|
- "{{ ssh_key_name }}"
|
||||||
|
image: "{{ item.image }}"
|
||||||
|
location: "{{ item.location | default(omit) }}"
|
||||||
|
datacenter: "{{ item.datacenter | default(omit) }}"
|
||||||
|
user_data: "{{ item.user_data | default(omit) }}"
|
||||||
|
api_token: "{{ lookup('env', 'HCLOUD_TOKEN') }}"
|
||||||
|
state: present
|
||||||
|
register: server
|
||||||
|
loop: "{{ molecule_yml.platforms }}"
|
||||||
|
async: 7200
|
||||||
|
poll: 0
|
||||||
|
|
||||||
|
- name: Wait for instance(s) creation to complete
|
||||||
|
async_status:
|
||||||
|
jid: "{{ item.ansible_job_id }}"
|
||||||
|
register: hetzner_jobs
|
||||||
|
until: hetzner_jobs.finished
|
||||||
|
retries: 300
|
||||||
|
loop: "{{ server.results }}"
|
||||||
|
|
||||||
|
- name: Create volume(s)
|
||||||
|
hcloud_volume:
|
||||||
|
name: "{{ item.name }}"
|
||||||
|
server: "{{ item.name }}"
|
||||||
|
location: "{{ item.location | default(omit) }}"
|
||||||
|
size: "{{ item.volume_size | default(10) }}"
|
||||||
|
api_token: "{{ lookup('env', 'HCLOUD_TOKEN') }}"
|
||||||
|
state: "present"
|
||||||
|
loop: "{{ molecule_yml.platforms }}"
|
||||||
|
when: item.volume | default(False) | bool
|
||||||
|
register: volumes
|
||||||
|
async: 7200
|
||||||
|
poll: 0
|
||||||
|
|
||||||
|
- name: Wait for volume(s) creation to complete
|
||||||
|
async_status:
|
||||||
|
jid: "{{ item.ansible_job_id }}"
|
||||||
|
register: hetzner_volumes
|
||||||
|
until: hetzner_volumes.finished
|
||||||
|
retries: 300
|
||||||
|
when: volumes.changed
|
||||||
|
loop: "{{ volumes.results }}"
|
||||||
|
|
||||||
|
# Mandatory configuration for Molecule to function.
|
||||||
|
|
||||||
|
- name: Populate instance config dict
|
||||||
|
set_fact:
|
||||||
|
instance_conf_dict:
|
||||||
|
{
|
||||||
|
"instance": "{{ item.hcloud_server.name }}",
|
||||||
|
"ssh_key_name": "{{ ssh_key_name }}",
|
||||||
|
"address": "{{ item.hcloud_server.ipv4_address }}",
|
||||||
|
"user": "{{ ssh_user }}",
|
||||||
|
"port": "{{ ssh_port }}",
|
||||||
|
"identity_file": "{{ ssh_path }}",
|
||||||
|
"volume": "{{ item.item.item.volume | default(False) | bool }}",
|
||||||
|
}
|
||||||
|
loop: "{{ hetzner_jobs.results }}"
|
||||||
|
register: instance_config_dict
|
||||||
|
when: server.changed | bool
|
||||||
|
|
||||||
|
- name: Convert instance config dict to a list
|
||||||
|
set_fact:
|
||||||
|
instance_conf: "{{ instance_config_dict.results | map(attribute='ansible_facts.instance_conf_dict') | list }}"
|
||||||
|
when: server.changed | bool
|
||||||
|
|
||||||
|
- name: Dump instance config
|
||||||
|
copy:
|
||||||
|
content: |
|
||||||
|
# Molecule managed
|
||||||
|
|
||||||
|
{{ instance_conf | to_nice_yaml(indent=2) }}
|
||||||
|
dest: "{{ molecule_instance_config }}"
|
||||||
|
when: server.changed | bool
|
||||||
|
|
||||||
|
- name: Wait for SSH
|
||||||
|
wait_for:
|
||||||
|
port: "{{ ssh_port }}"
|
||||||
|
host: "{{ item.address }}"
|
||||||
|
search_regex: SSH
|
||||||
|
delay: 10
|
||||||
|
loop: "{{ lookup('file', molecule_instance_config) | from_yaml }}"
|
||||||
|
|
||||||
|
- name: Wait for VM to settle down
|
||||||
|
pause:
|
||||||
|
seconds: 30
|
78
molecule/rocky8/destroy.yml
Normal file
78
molecule/rocky8/destroy.yml
Normal file
@ -0,0 +1,78 @@
|
|||||||
|
---
|
||||||
|
- name: Destroy
|
||||||
|
hosts: localhost
|
||||||
|
connection: local
|
||||||
|
gather_facts: false
|
||||||
|
no_log: "{{ molecule_no_log }}"
|
||||||
|
tasks:
|
||||||
|
- name: Check existing instance config file
|
||||||
|
stat:
|
||||||
|
path: "{{ molecule_instance_config }}"
|
||||||
|
register: cfg
|
||||||
|
|
||||||
|
- name: Populate the instance config
|
||||||
|
set_fact:
|
||||||
|
instance_conf: "{{ (lookup('file', molecule_instance_config) | from_yaml) if cfg.stat.exists else [] }}"
|
||||||
|
|
||||||
|
- name: Destroy molecule instance(s)
|
||||||
|
hcloud_server:
|
||||||
|
name: "{{ item.instance }}"
|
||||||
|
api_token: "{{ lookup('env', 'HCLOUD_TOKEN') }}"
|
||||||
|
state: absent
|
||||||
|
register: server
|
||||||
|
loop: "{{ instance_conf }}"
|
||||||
|
async: 7200
|
||||||
|
poll: 0
|
||||||
|
|
||||||
|
- name: Wait for instance(s) deletion to complete
|
||||||
|
async_status:
|
||||||
|
jid: "{{ item.ansible_job_id }}"
|
||||||
|
register: hetzner_jobs
|
||||||
|
until: hetzner_jobs.finished
|
||||||
|
retries: 300
|
||||||
|
loop: "{{ server.results }}"
|
||||||
|
|
||||||
|
- pause:
|
||||||
|
seconds: 5
|
||||||
|
|
||||||
|
- name: Destroy volume(s)
|
||||||
|
hcloud_volume:
|
||||||
|
name: "{{ item.instance }}"
|
||||||
|
server: "{{ item.instance }}"
|
||||||
|
api_token: "{{ lookup('env', 'HCLOUD_TOKEN') }}"
|
||||||
|
state: "absent"
|
||||||
|
register: volumes
|
||||||
|
loop: "{{ instance_conf }}"
|
||||||
|
when: item.volume | default(False) | bool
|
||||||
|
async: 7200
|
||||||
|
poll: 0
|
||||||
|
|
||||||
|
- name: Wait for volume(s) deletion to complete
|
||||||
|
async_status:
|
||||||
|
jid: "{{ item.ansible_job_id }}"
|
||||||
|
register: hetzner_volumes
|
||||||
|
until: hetzner_volumes.finished
|
||||||
|
retries: 300
|
||||||
|
when: volumes.changed
|
||||||
|
loop: "{{ volumes.results }}"
|
||||||
|
|
||||||
|
- name: Remove registered SSH key
|
||||||
|
hcloud_ssh_key:
|
||||||
|
name: "{{ instance_conf[0].ssh_key_name }}"
|
||||||
|
state: absent
|
||||||
|
when: (instance_conf | default([])) | length > 0
|
||||||
|
|
||||||
|
# Mandatory configuration for Molecule to function.
|
||||||
|
|
||||||
|
- name: Populate instance config
|
||||||
|
set_fact:
|
||||||
|
instance_conf: {}
|
||||||
|
|
||||||
|
- name: Dump instance config
|
||||||
|
copy:
|
||||||
|
content: |
|
||||||
|
# Molecule managed
|
||||||
|
|
||||||
|
{{ instance_conf | to_nice_yaml(indent=2) }}
|
||||||
|
dest: "{{ molecule_instance_config }}"
|
||||||
|
when: server.changed | bool
|
24
molecule/rocky8/molecule.yml
Normal file
24
molecule/rocky8/molecule.yml
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
---
|
||||||
|
dependency:
|
||||||
|
name: galaxy
|
||||||
|
options:
|
||||||
|
role-file: molecule/requirements.yml
|
||||||
|
requirements-file: molecule/requirements.yml
|
||||||
|
env:
|
||||||
|
ANSIBLE_GALAXY_DISPLAY_PROGRESS: "false"
|
||||||
|
driver:
|
||||||
|
name: delegated
|
||||||
|
platforms:
|
||||||
|
- name: rocky8-postgres
|
||||||
|
image: rocky-8
|
||||||
|
server_type: cx11
|
||||||
|
lint: |
|
||||||
|
/usr/local/bin/flake8
|
||||||
|
provisioner:
|
||||||
|
name: ansible
|
||||||
|
env:
|
||||||
|
ANSIBLE_FILTER_PLUGINS: ${ANSIBLE_FILTER_PLUGINS:-./plugins/filter}
|
||||||
|
ANSIBLE_LIBRARY: ${ANSIBLE_LIBRARY:-./library}
|
||||||
|
log: False
|
||||||
|
verifier:
|
||||||
|
name: testinfra
|
15
molecule/rocky8/prepare.yml
Normal file
15
molecule/rocky8/prepare.yml
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
---
|
||||||
|
- name: Prepare
|
||||||
|
hosts: all
|
||||||
|
gather_facts: false
|
||||||
|
tasks:
|
||||||
|
- name: Bootstrap python for Ansible
|
||||||
|
raw: |
|
||||||
|
command -v python3 python || (
|
||||||
|
(test -e /usr/bin/dnf && sudo dnf install -y python3) ||
|
||||||
|
(test -e /usr/bin/apt && (apt -y update && apt install -y python-minimal)) ||
|
||||||
|
(test -e /usr/bin/yum && sudo yum -y -qq install python3) ||
|
||||||
|
echo "Warning: Python not boostrapped due to unknown platform."
|
||||||
|
)
|
||||||
|
become: true
|
||||||
|
changed_when: false
|
28
molecule/rocky8/tests/test_default.py
Normal file
28
molecule/rocky8/tests/test_default.py
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
import os
|
||||||
|
|
||||||
|
import testinfra.utils.ansible_runner
|
||||||
|
|
||||||
|
testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner(
|
||||||
|
os.environ["MOLECULE_INVENTORY_FILE"]
|
||||||
|
).get_hosts("all")
|
||||||
|
|
||||||
|
|
||||||
|
def test_postgres_is_installed(host):
|
||||||
|
postgres = host.package("postgresql14-server")
|
||||||
|
assert postgres.is_installed
|
||||||
|
|
||||||
|
|
||||||
|
def test_postgres_running_and_enabled(host):
|
||||||
|
postgres = host.service("postgresql-14")
|
||||||
|
assert postgres.is_running
|
||||||
|
assert postgres.is_enabled
|
||||||
|
|
||||||
|
|
||||||
|
def test_postgres_auth(host):
|
||||||
|
login = host.run("PGPASSWORD=secure psql -U pgdemo -h localhost -c 'select 1' -q demo")
|
||||||
|
assert login.succeeded
|
||||||
|
|
||||||
|
|
||||||
|
def test_postgres_socket(host):
|
||||||
|
# Verify the socket is listening for HTTP traffic
|
||||||
|
assert host.socket("tcp://127.0.0.1:5432").is_listening
|
@ -24,7 +24,7 @@
|
|||||||
users: "{{ item.users | default(['all']) | join(',') }}"
|
users: "{{ item.users | default(['all']) | join(',') }}"
|
||||||
address: "{{ item.address | default('all') }}"
|
address: "{{ item.address | default('all') }}"
|
||||||
databases: "{{ item.databases | default(['all']) | join(',') }}"
|
databases: "{{ item.databases | default(['all']) | join(',') }}"
|
||||||
method: "{{ item.auth_method | default('md5') }}"
|
method: "{{ item.auth_method | default(postgres_password_encryption) }}"
|
||||||
state: "{{ item.state | default('present') }}"
|
state: "{{ item.state | default('present') }}"
|
||||||
loop: "{{ postgres_hba_entries + postgres_hba_entries_extra }}"
|
loop: "{{ postgres_hba_entries + postgres_hba_entries_extra }}"
|
||||||
loop_control:
|
loop_control:
|
||||||
|
@ -1,5 +1,17 @@
|
|||||||
---
|
---
|
||||||
- import_tasks: prepare.yml
|
- import_tasks: prepare.yml
|
||||||
|
|
||||||
|
- include_tasks: "{{ task_files }}"
|
||||||
|
vars:
|
||||||
|
task_files: "{{ lookup('first_found', params, errors='ignore') }}"
|
||||||
|
params:
|
||||||
|
files:
|
||||||
|
- "prepare_{{ ansible_os_family | lower }}_{{ ansible_distribution_major_version }}.yml"
|
||||||
|
- "prepare_{{ ansible_os_family | lower }}.yml"
|
||||||
|
paths:
|
||||||
|
- "tasks"
|
||||||
|
when: task_files
|
||||||
|
|
||||||
- import_tasks: install.yml
|
- import_tasks: install.yml
|
||||||
- import_tasks: config.yml
|
- import_tasks: config.yml
|
||||||
- import_tasks: tls.yml
|
- import_tasks: tls.yml
|
||||||
|
@ -23,9 +23,11 @@
|
|||||||
become_user: "{{ postgres_user }}"
|
become_user: "{{ postgres_user }}"
|
||||||
|
|
||||||
- name: Ensure PostgreSQL users are present
|
- name: Ensure PostgreSQL users are present
|
||||||
|
environment:
|
||||||
|
PGOPTIONS: "-c password_encryption={{ postgres_password_encryption }}"
|
||||||
postgresql_user:
|
postgresql_user:
|
||||||
name: "{{ item.name }}"
|
name: "{{ item.name }}"
|
||||||
password: "{{ 'md5' + (item.password + item.name) | hash('md5') }}"
|
password: "{{ item.password | default(omit) }}"
|
||||||
encrypted: "{{ item.encrypted | default('yes') }}"
|
encrypted: "{{ item.encrypted | default('yes') }}"
|
||||||
priv: "{{ item.priv | default(omit) }}"
|
priv: "{{ item.priv | default(omit) }}"
|
||||||
role_attr_flags: "{{ item.role_attr_flags | default(omit) }}"
|
role_attr_flags: "{{ item.role_attr_flags | default(omit) }}"
|
||||||
|
@ -1,24 +1,13 @@
|
|||||||
---
|
---
|
||||||
- name: Load helper variables
|
- name: Add PostgreSQL repository
|
||||||
include_vars: "main.yml"
|
yum_repository:
|
||||||
|
name: "postgresql-{{ __postgres_version }}"
|
||||||
- block:
|
file: "{{ postgres_repository_filename }}"
|
||||||
- name: Add PostgreSQL repository
|
description: "PostgreSQL {{ __postgres_version }} yum repository"
|
||||||
yum_repository:
|
baseurl: "https://download.postgresql.org/pub/repos/yum/{{ __postgres_version }}/redhat/rhel-{{ ansible_distribution_major_version }}-{{ ansible_architecture }}"
|
||||||
name: "postgresql-{{ __postgres_version }}"
|
gpgcheck: yes
|
||||||
file: "{{ postgres_repository_filename }}"
|
enabled: yes
|
||||||
description: "PostgreSQL {{ __postgres_version }} yum repository"
|
gpgkey: "https://download.postgresql.org/pub/repos/yum/RPM-GPG-KEY-PGDG-{{ __postgres_version }}"
|
||||||
baseurl: "https://download.postgresql.org/pub/repos/yum/{{ __postgres_version }}/redhat/rhel-{{ ansible_distribution_major_version }}-{{ ansible_architecture }}"
|
|
||||||
gpgcheck: yes
|
|
||||||
enabled: yes
|
|
||||||
gpgkey: "https://download.postgresql.org/pub/repos/yum/RPM-GPG-KEY-PGDG-{{ __postgres_version }}"
|
|
||||||
|
|
||||||
- name: Install dependencies
|
|
||||||
package:
|
|
||||||
name: "{{ item }}"
|
|
||||||
state: present
|
|
||||||
loop:
|
|
||||||
- python2-psycopg2
|
|
||||||
become: True
|
become: True
|
||||||
become_user: root
|
become_user: root
|
||||||
when: postgres_repository_enabled | bool
|
when: postgres_repository_enabled | bool
|
||||||
|
9
tasks/prepare_redhat_7.yml
Normal file
9
tasks/prepare_redhat_7.yml
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
---
|
||||||
|
- name: Install rh7 dependencies
|
||||||
|
package:
|
||||||
|
name: "{{ item }}"
|
||||||
|
state: present
|
||||||
|
loop:
|
||||||
|
- python-psycopg2
|
||||||
|
become: True
|
||||||
|
become_user: root
|
24
tasks/prepare_redhat_8.yml
Normal file
24
tasks/prepare_redhat_8.yml
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
---
|
||||||
|
- block:
|
||||||
|
- name: Disable default Postgres module
|
||||||
|
copy:
|
||||||
|
dest: /etc/dnf/modules.d/postgresql.module
|
||||||
|
content: |
|
||||||
|
[postgresql]
|
||||||
|
name=postgresql
|
||||||
|
stream=
|
||||||
|
profiles=
|
||||||
|
state=disabled
|
||||||
|
mode: 0644
|
||||||
|
owner: root
|
||||||
|
group: root
|
||||||
|
when: postgres_repository_enabled | bool
|
||||||
|
|
||||||
|
- name: Install rh8 dependencies
|
||||||
|
package:
|
||||||
|
name: "{{ item }}"
|
||||||
|
state: present
|
||||||
|
loop:
|
||||||
|
- python3-psycopg2
|
||||||
|
become: True
|
||||||
|
become_user: root
|
@ -2,23 +2,6 @@
|
|||||||
# -----------------------------
|
# -----------------------------
|
||||||
# PostgreSQL configuration file
|
# PostgreSQL configuration file
|
||||||
# -----------------------------
|
# -----------------------------
|
||||||
#
|
|
||||||
# This file consists of lines of the form:
|
|
||||||
#
|
|
||||||
# name = value
|
|
||||||
#
|
|
||||||
# (The "=" is optional.) Whitespace may be used. Comments are introduced with
|
|
||||||
# "#" anywhere on a line. The complete list of parameter names and allowed
|
|
||||||
# values can be found in the PostgreSQL documentation.
|
|
||||||
|
|
||||||
|
|
||||||
#------------------------------------------------------------------------------
|
|
||||||
# FILE LOCATIONS
|
|
||||||
#------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
# The default values of these variables are driven from the -D command-line
|
|
||||||
# option or PGDATA environment variable, represented here as ConfigDir.
|
|
||||||
|
|
||||||
|
|
||||||
#------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------
|
||||||
# CONNECTIONS AND AUTHENTICATION
|
# CONNECTIONS AND AUTHENTICATION
|
||||||
@ -29,262 +12,75 @@
|
|||||||
listen_addresses = '{{ postgres_connection_addresses | join(",") }}'
|
listen_addresses = '{{ postgres_connection_addresses | join(",") }}'
|
||||||
port = {{ postgres_connection_port }}
|
port = {{ postgres_connection_port }}
|
||||||
max_connections = 100
|
max_connections = 100
|
||||||
#superuser_reserved_connections = 3
|
|
||||||
unix_socket_directories = '{{ postgres_socket_directories | join(",") }}'
|
unix_socket_directories = '{{ postgres_socket_directories | join(",") }}'
|
||||||
#unix_socket_group = ''
|
|
||||||
#unix_socket_permissions = 0777
|
|
||||||
#bonjour = off
|
|
||||||
#bonjour_name = ''
|
|
||||||
|
|
||||||
# - Security and Authentication -
|
# - Authentication -
|
||||||
|
|
||||||
|
authentication_timeout = 1min
|
||||||
|
password_encryption = {{ postgres_password_encryption }}
|
||||||
|
|
||||||
|
# - SSL -
|
||||||
|
|
||||||
#authentication_timeout = 1min
|
|
||||||
{% if postgres_tls_enabled %}
|
{% if postgres_tls_enabled %}
|
||||||
ssl = on
|
ssl = on
|
||||||
|
ssl_cert_file = '{{ __postgres_tls_cert_path }}'
|
||||||
|
ssl_key_file = '{{ __postgres_tls_key_path }}'
|
||||||
{% else %}
|
{% else %}
|
||||||
ssl = off
|
ssl = off
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% if postgres_tls_enabled %}
|
|
||||||
#ssl_ciphers = 'HIGH:MEDIUM:+3DES:!aNULL'
|
|
||||||
#ssl_prefer_server_ciphers = on
|
|
||||||
#ssl_ecdh_curve = 'prime256v1'
|
|
||||||
#ssl_dh_params_file = ''
|
|
||||||
ssl_cert_file = '{{ __postgres_tls_cert_path }}'
|
|
||||||
ssl_key_file = '{{ __postgres_tls_key_path }}'
|
|
||||||
#ssl_ca_file = ''
|
|
||||||
#ssl_crl_file = ''
|
|
||||||
{% endif %}
|
|
||||||
password_encryption = {{ postgres_password_encryption }}
|
|
||||||
#db_user_namespace = off
|
|
||||||
#row_security = on
|
|
||||||
|
|
||||||
# GSSAPI using Kerberos
|
|
||||||
#krb_server_keyfile = ''
|
|
||||||
#krb_caseins_users = off
|
|
||||||
|
|
||||||
# - TCP Keepalives -
|
|
||||||
# see "man 7 tcp" for details
|
|
||||||
|
|
||||||
#tcp_keepalives_idle = 0
|
|
||||||
#tcp_keepalives_interval = 0
|
|
||||||
#tcp_keepalives_count = 0
|
|
||||||
|
|
||||||
|
|
||||||
#------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------
|
||||||
# RESOURCE USAGE (except WAL)
|
# RESOURCE USAGE (except WAL)
|
||||||
#------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
# - Memory -
|
||||||
|
|
||||||
shared_buffers = 128MB
|
shared_buffers = 128MB
|
||||||
dynamic_shared_memory_type = posix
|
dynamic_shared_memory_type = posix
|
||||||
|
|
||||||
# - Disk -
|
|
||||||
|
|
||||||
# - Kernel Resource Usage -
|
|
||||||
|
|
||||||
# - Cost-Based Vacuum Delay -
|
|
||||||
|
|
||||||
# - Background Writer -
|
|
||||||
|
|
||||||
# - Asynchronous Behavior -
|
|
||||||
|
|
||||||
|
|
||||||
#------------------------------------------------------------------------------
|
|
||||||
# WRITE AHEAD LOG
|
|
||||||
#------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
# - Settings -
|
|
||||||
|
|
||||||
# - Checkpoints -
|
# - Checkpoints -
|
||||||
|
|
||||||
# - Archiving -
|
max_wal_size = 1GB
|
||||||
|
min_wal_size = 80MB
|
||||||
|
|
||||||
|
|
||||||
#------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------
|
||||||
# REPLICATION
|
# REPORTING AND LOGGING
|
||||||
#------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
# - Sending Server(s) -
|
|
||||||
|
|
||||||
# Set these on the master and on any standby that will send replication data.
|
|
||||||
|
|
||||||
# - Master Server -
|
|
||||||
|
|
||||||
# These settings are ignored on a standby server.
|
|
||||||
|
|
||||||
# - Standby Servers -
|
|
||||||
|
|
||||||
# These settings are ignored on a master server.
|
|
||||||
|
|
||||||
# - Subscribers -
|
|
||||||
|
|
||||||
# These settings are ignored on a publisher.
|
|
||||||
|
|
||||||
|
|
||||||
#------------------------------------------------------------------------------
|
|
||||||
# QUERY TUNING
|
|
||||||
#------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
# - Planner Method Configuration -
|
|
||||||
|
|
||||||
# - Planner Cost Constants -
|
|
||||||
|
|
||||||
# - Genetic Query Optimizer -
|
|
||||||
|
|
||||||
# - Other Planner Options -
|
|
||||||
|
|
||||||
|
|
||||||
#------------------------------------------------------------------------------
|
|
||||||
# ERROR REPORTING AND LOGGING
|
|
||||||
#------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------
|
||||||
|
|
||||||
# - Where to Log -
|
# - Where to Log -
|
||||||
|
|
||||||
log_destination = '{{ postgres_log_destination | join(",") }}'
|
log_destination = '{{ postgres_log_destination | join(",") }}'
|
||||||
# This is used when logging to stderr:
|
|
||||||
{% if "stderr" in postgres_log_destination or "csvlog" in postgres_log_destination %}
|
{% if "stderr" in postgres_log_destination or "csvlog" in postgres_log_destination %}
|
||||||
logging_collector = on
|
logging_collector = on
|
||||||
{% else %}
|
{% else %}
|
||||||
logging_collector = off
|
logging_collector = off
|
||||||
{% endif %}
|
{% endif %}
|
||||||
# These are only used if logging_collector is on:
|
|
||||||
log_directory = '{{ postgres_log_directory }}'
|
log_directory = '{{ postgres_log_directory }}'
|
||||||
log_filename = '{{ postgres_log_filename }}'
|
log_filename = '{{ postgres_log_filename }}'
|
||||||
#log_file_mode = 0600
|
|
||||||
log_truncate_on_rotation = on
|
|
||||||
log_rotation_age = {{ postgres_log_rotation_age }}
|
log_rotation_age = {{ postgres_log_rotation_age }}
|
||||||
log_rotation_size = {{ postgres_log_rotation_size }}
|
log_rotation_size = {{ postgres_log_rotation_size }}
|
||||||
|
log_truncate_on_rotation = on
|
||||||
|
|
||||||
# These are relevant when logging to syslog:
|
|
||||||
#syslog_facility = 'LOCAL0'
|
|
||||||
#syslog_ident = 'postgres'
|
|
||||||
#syslog_sequence_numbers = on
|
|
||||||
#syslog_split_messages = on
|
|
||||||
|
|
||||||
# - When to Log -
|
|
||||||
#client_min_messages = notice
|
|
||||||
#log_min_messages = warning
|
|
||||||
#log_min_error_statement = error
|
|
||||||
#log_min_duration_statement = -1
|
|
||||||
|
|
||||||
# - What to Log -
|
# - What to Log -
|
||||||
#debug_print_parse = off
|
|
||||||
#debug_print_rewritten = off
|
|
||||||
#debug_print_plan = off
|
|
||||||
#debug_pretty_print = on
|
|
||||||
#log_checkpoints = off
|
|
||||||
#log_connections = off
|
|
||||||
#log_disconnections = off
|
|
||||||
#log_duration = off
|
|
||||||
#log_error_verbosity = default # terse, default, or verbose messages
|
|
||||||
#log_hostname = off
|
|
||||||
log_line_prefix = '%m [%p] '
|
log_line_prefix = '%m [%p] '
|
||||||
#log_lock_waits = off
|
log_timezone = 'Etc/UTC'
|
||||||
#log_statement = 'none'
|
|
||||||
#log_replication_commands = off
|
|
||||||
#log_temp_files = -1
|
|
||||||
log_timezone = 'Europe/Berlin'
|
|
||||||
|
|
||||||
|
|
||||||
# - Process Title -
|
|
||||||
|
|
||||||
#cluster_name = ''
|
|
||||||
#update_process_title = on
|
|
||||||
|
|
||||||
|
|
||||||
#------------------------------------------------------------------------------
|
|
||||||
# RUNTIME STATISTICS
|
|
||||||
#------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
# - Query/Index Statistics Collector -
|
|
||||||
|
|
||||||
# - Statistics Monitoring -
|
|
||||||
|
|
||||||
|
|
||||||
#------------------------------------------------------------------------------
|
|
||||||
# AUTOVACUUM PARAMETERS
|
|
||||||
#------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
|
|
||||||
#------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------
|
||||||
# CLIENT CONNECTION DEFAULTS
|
# CLIENT CONNECTION DEFAULTS
|
||||||
#------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------
|
||||||
|
|
||||||
# - Statement Behavior -
|
|
||||||
|
|
||||||
# - Locale and Formatting -
|
# - Locale and Formatting -
|
||||||
|
|
||||||
datestyle = 'iso, mdy'
|
datestyle = 'iso, mdy'
|
||||||
#intervalstyle = 'postgres'
|
timezone = 'Etc/UTC'
|
||||||
timezone = 'Europe/Berlin'
|
|
||||||
#timezone_abbreviations = 'Default'
|
|
||||||
#extra_float_digits = 0
|
|
||||||
#client_encoding = sql_ascii
|
|
||||||
|
|
||||||
# These settings are initialized by initdb, but they can be changed.
|
|
||||||
lc_messages = 'en_US.UTF-8'
|
lc_messages = 'en_US.UTF-8'
|
||||||
lc_monetary = 'en_US.UTF-8'
|
lc_monetary = 'en_US.UTF-8' # locale for monetary formatting
|
||||||
lc_numeric = 'en_US.UTF-8'
|
lc_numeric = 'en_US.UTF-8' # locale for number formatting
|
||||||
lc_time = 'en_US.UTF-8'
|
lc_time = 'en_US.UTF-8' # locale for time formatting
|
||||||
|
|
||||||
# default configuration for text search
|
|
||||||
default_text_search_config = 'pg_catalog.english'
|
default_text_search_config = 'pg_catalog.english'
|
||||||
|
|
||||||
# - Other Defaults -
|
|
||||||
|
|
||||||
#dynamic_library_path = '$libdir'
|
|
||||||
#local_preload_libraries = ''
|
|
||||||
#session_preload_libraries = ''
|
|
||||||
|
|
||||||
|
|
||||||
#------------------------------------------------------------------------------
|
|
||||||
# LOCK MANAGEMENT
|
|
||||||
#------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
|
|
||||||
#------------------------------------------------------------------------------
|
|
||||||
# VERSION/PLATFORM COMPATIBILITY
|
|
||||||
#------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
# - Previous PostgreSQL Versions -
|
|
||||||
|
|
||||||
#array_nulls = on
|
|
||||||
#backslash_quote = safe_encoding
|
|
||||||
#default_with_oids = off
|
|
||||||
#escape_string_warning = on
|
|
||||||
#lo_compat_privileges = off
|
|
||||||
#operator_precedence_warning = off
|
|
||||||
#quote_all_identifiers = off
|
|
||||||
#standard_conforming_strings = on
|
|
||||||
#synchronize_seqscans = on
|
|
||||||
|
|
||||||
# - Other Platforms and Clients -
|
|
||||||
|
|
||||||
#transform_null_equals = off
|
|
||||||
|
|
||||||
|
|
||||||
#------------------------------------------------------------------------------
|
|
||||||
# ERROR HANDLING
|
|
||||||
#------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
#exit_on_error = off # terminate session on any error?
|
|
||||||
#restart_after_crash = on # reinitialize after backend crash?
|
|
||||||
|
|
||||||
|
|
||||||
#------------------------------------------------------------------------------
|
|
||||||
# CONFIG FILE INCLUDES
|
|
||||||
#------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
# These options allow settings to be loaded from files other than the
|
|
||||||
# default postgresql.conf.
|
|
||||||
|
|
||||||
#include_dir = 'conf.d'
|
|
||||||
#include_if_exists = 'exists.conf'
|
|
||||||
#include = 'special.conf'
|
|
||||||
|
|
||||||
|
|
||||||
#------------------------------------------------------------------------------
|
|
||||||
# CUSTOMIZED OPTIONS
|
|
||||||
#------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
# Add settings for extensions here
|
|
||||||
|
Loading…
Reference in New Issue
Block a user