test: add support debian 12

This commit is contained in:
Adrien Waksberg 2023-08-28 14:55:55 +02:00
parent 521d372dd8
commit 003f104851
7 changed files with 31 additions and 24 deletions

View file

@ -8,18 +8,24 @@ Which is based on [Keep A Changelog](http://keepachangelog.com/)
### Changed
- break: new system for user and privileges
- break: default postgresql version is 15
### Added
- add database owner
- add variable postrgresql_primary
- add user attributes
- test: add support debian 12
### Fixed
- fix replication database in pg_hba
- fix pg_hba when multiple users or multiple databases
### Removed
- test: remove support debian 10
## v1.0.0 - 2021-09-10
- first version

View file

@ -7,16 +7,16 @@ Install and configure Postgresql
## Requirements
* Ansible >= 2.9
* Ansible >= 2.10
* Debian
* Buster
* Bullseye
* Bookworm
## Role variables
| Name | Type | Required |Default | Comment |
|------------------------------------|-------|----------|--------|-----------------------------------------------------|
| postgresql_version | str | no | 13 | the major version to use |
| postgresql_version | str | no | 15 | the major version to use |
| postgresql_use_official_repository | bool | no | false | set true if you want official postgresql repository |
| postgresql_primary | bool | no | false | set true to create user and database on this server |
| postgresql_config | dict | no | | add option config file |

View file

@ -1,5 +1,5 @@
---
postgresql_version: 13
postgresql_version: 15
postgresql_use_official_repository: false
postgresql_primary: false
postgresql_databases: []
@ -25,7 +25,6 @@ postgresql_config_default:
log_line_prefix: '%m [%p] %q%u@%d'
log_timezone: Etc/UTC
cluster_name: '{{ postgresql_version }}/main'
stats_temp_directory: '/var/run/postgresql/{{ postgresql_version }}-main.pg_stat_tmp'
datestyle: iso, mdy
timezone: Etc/UTC
lc_messages: C.UTF-8

View file

@ -6,13 +6,13 @@ galaxy_info:
company: Adrien Waksberg
description: Install and configure postgresql
license: Apache2
min_ansible_version: 2.9
min_ansible_version: "2.10"
platforms:
- name: Debian
versions:
- buster
- bullseye
- bookworm
galaxy_tags:
- database

View file

@ -7,7 +7,7 @@
postgresql_use_official_repository: true
postgresql_primary: true
postgresql_config:
listen_addresses: '*'
listen_addresses: "*"
postgresql_hba:
- type: local
databases:
@ -30,14 +30,14 @@
- INHERIT
postgresql_privileges:
- role: myuser
type: database
type: schema
database: myappli
objets:
- myappli
- public
privileges:
- ALL
pre_tasks:
- name: update apt cache
- name: Update apt cache
ansible.builtin.apt:
update_cache: true

View file

@ -2,19 +2,21 @@
driver:
name: docker
platforms:
- name: debian12
image: nishiki/debian12:molecule
privileged: true
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:rw
cgroupns_mode: host
command: /bin/systemd
capabilities:
- SYS_ADMIN
- name: debian11
image: nishiki/debian11:molecule
privileged: true
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:ro
command: /bin/systemd
capabilities:
- SYS_ADMIN
- name: debian10
image: nishiki/debian10:molecule
privileged: true
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:ro
- /sys/fs/cgroup:/sys/fs/cgroup:rw
cgroupns_mode: host
command: /bin/systemd
capabilities:
- SYS_ADMIN

View file

@ -1,12 +1,12 @@
import testinfra.utils.ansible_runner
def test_packages(host):
for package_name in ['postgresql-13', 'python3-psycopg2']:
for package_name in ['postgresql-15', 'python3-psycopg2']:
package = host.package(package_name)
assert package.is_installed
def test_config_file(host):
path = host.file('/etc/postgresql/13/main/postgresql.conf')
path = host.file('/etc/postgresql/15/main/postgresql.conf')
assert path.exists
assert path.is_file
assert path.user == 'root'
@ -15,7 +15,7 @@ def test_config_file(host):
assert path.contains("listen_addresses = '*'")
def test_hba_file(host):
path = host.file('/etc/postgresql/13/main/pg_hba.conf')
path = host.file('/etc/postgresql/15/main/pg_hba.conf')
assert path.exists
assert path.is_file
assert path.user == 'root'
@ -24,7 +24,7 @@ def test_hba_file(host):
assert path.contains('local "myappli","myappli2" all md5')
def test_service(host):
service = host.service('postgresql@13-main')
service = host.service('postgresql@15-main')
assert service.is_running
assert service.is_enabled