Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move pg_hba.conf to configuration directory #17

Merged
merged 4 commits into from
Mar 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions .github/workflows/molecule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,11 @@ jobs:
matrix:
scenario:
- deploy
- stopped
- masked
- stop
- mask
- databases
- configure
- initdb
image:
- name: ubuntu2204
command: /lib/systemd/systemd
Expand All @@ -34,6 +35,11 @@ jobs:
command: /lib/systemd/systemd
- name: rockylinux9
command: /usr/lib/systemd/systemd
exclude:
- scenario: initdb
image:
name: rockylinux9
command: /usr/lib/systemd/systemd

steps:
- name: Check out the codebase
Expand Down
2 changes: 1 addition & 1 deletion molecule/configure/molecule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ dependency:
driver:
name: docker
platforms:
- name: postgresql-install-01
- name: postgresql-configure-01
image: "geerlingguy/docker-${MOLECULE_DOCKER_IMAGE:-ubuntu2204}-ansible:latest"
command: ${MOLECULE_DOCKER_COMMAND:-""}
cgroupns_mode: host
Expand Down
2 changes: 1 addition & 1 deletion molecule/databases/molecule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ dependency:
driver:
name: docker
platforms:
- name: postgresql-install-01
- name: postgresql-databases-01
image: "geerlingguy/docker-${MOLECULE_DOCKER_IMAGE:-ubuntu2204}-ansible:latest"
command: ${MOLECULE_DOCKER_COMMAND:-""}
cgroupns_mode: host
Expand Down
2 changes: 1 addition & 1 deletion molecule/deploy/molecule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ dependency:
driver:
name: docker
platforms:
- name: postgresql-install-01
- name: postgresql-deploy-01
image: "geerlingguy/docker-${MOLECULE_DOCKER_IMAGE:-ubuntu2204}-ansible:latest"
command: ${MOLECULE_DOCKER_COMMAND:-""}
cgroupns_mode: host
Expand Down
59 changes: 59 additions & 0 deletions molecule/initdb/molecule.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
---
dependency:
name: galaxy
options:
role-file: requirements.yml
requirements-file: requirements.yml
driver:
name: docker
platforms:
- name: postgresql-initdb-01
image: "geerlingguy/docker-${MOLECULE_DOCKER_IMAGE:-ubuntu2204}-ansible:latest"
command: ${MOLECULE_DOCKER_COMMAND:-""}
cgroupns_mode: host
privileged: true
pre_build_image: true
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:rw
tmpfs:
- /tmp
- /opt
provisioner:
name: ansible
playbooks:
prepare: ../common/prepare.yml
converge: ../common/converge.yml
side_effect: ../common/converge.yml
config_options:
defaults:
callbacks_enabled: ansible.posix.profile_tasks
inventory:
hosts:
all:
vars:
postgresql_nolog: false
postgresql_initdb: false
postgresql_service_state: stopped
postgresql_service_masked: true
postgresql_service_enabled: false
postgresql_pip_manage: false
verifier:
name: ansible
scenario:
prepare_sequence:
- prepare
create_sequence:
- create
converge_sequence:
- converge
destroy_sequence:
- destroy
cleanup_sequence:
- cleanup
test_sequence:
- dependency
- create
- prepare
- converge
- side_effect
- verify
34 changes: 34 additions & 0 deletions molecule/initdb/verify.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
---
- ansible.builtin.import_playbook: ../common/verify.yml

- name: Verify datadir
hosts: all
gather_facts: true
become: true
tasks:
- name: Import role defaults
ansible.builtin.include_role:
name: nephelaiio.postgresql
tasks_from: vars.yml

- name: Stat PostgreSQL datadir
ansible.builtin.stat:
path: "{{ _postgresql_datadir }}"
register: _datadir_query

- name: Verify PostgreSQL datadir
ansible.builtin.assert:
that: _datadir_query.stat.exists

- name: List PostgreSQL datadir files
ansible.builtin.find:
paths: "{{ _postgresql_datadir }}"
file_type: any
register: _datadir_files

- name: Verify PostgreSQL files
ansible.builtin.assert:
that: _files | length == 0
fail_msg: "Found datadir files [{{ _files | join(',') }}]"
vars:
_files: "{{ _datadir_files.files | map(attribute='path') }}"
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ dependency:
driver:
name: docker
platforms:
- name: postgresql-install-01
- name: postgresql-mask-01
image: "geerlingguy/docker-${MOLECULE_DOCKER_IMAGE:-ubuntu2204}-ansible:latest"
command: ${MOLECULE_DOCKER_COMMAND:-""}
cgroupns_mode: host
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ dependency:
driver:
name: docker
platforms:
- name: postgresql-install-01
- name: postgresql-stop-01
image: "geerlingguy/docker-${MOLECULE_DOCKER_IMAGE:-ubuntu2204}-ansible:latest"
command: ${MOLECULE_DOCKER_COMMAND:-""}
cgroupns_mode: host
Expand Down
17 changes: 17 additions & 0 deletions tasks/install.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,23 @@
vars:
_lock_state: install

- name: Configure cluster initialization for Debian distributions
when: ansible_os_family == "Debian"
block:
- name: Install postgresql common package
ansible.builtin.package:
name: postgresql-common

- name: Disable database initialization
ansible.builtin.copy:
dest: "/etc/postgresql-common/createcluster.conf"
content: |
create_main_cluster = off
owner: root
group: root
mode: 0644
when: not (_postgresql_initdb | bool)

- name: Install packages and configure package holds
block:
- name: Install postgresql packages
Expand Down
2 changes: 1 addition & 1 deletion tasks/vars.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
_postgresql_pgoptions: "{{ (_auth_method == _auth_scram_sha256) | ternary(_auth_scram_option, '') }}"
_postgresql_conf_include: "{{ _conf_include }}"
_postgresql_conf_main: "{{ _conf_main }}"
_postgresql_conf_hba: "{{ _conf_datadir }}/pg_hba.conf"
_postgresql_conf_hba: "{{ _conf_confdir }}/pg_hba.conf"
_postgresql_conf_ansible: "{{ _conf_include }}/{{ __postgresql_conf_ansible }}"
_postgresql_conf_pgaudit: "{{ _conf_include }}/{{ __postgresql_conf_pgaudit }}"
_postgresql_conf_pgcron: "{{ _conf_include }}/{{ __postgresql_conf_pgcron }}"
Expand Down