Compare commits
1 Commits
83a0f219b3
...
573f1df785
Author | SHA1 | Date | |
---|---|---|---|
573f1df785 |
@ -38,6 +38,15 @@ postgresql_container_etc_hosts: ~
|
||||
postgresql_container_restart_policy: "on-failure"
|
||||
postgresql_container_state: >-2
|
||||
{{ (postgresql_state == 'present') | ternary('started', 'absent') }}
|
||||
postgresql_container_volumes: ~
|
||||
postgresql_container_base_volumes:
|
||||
- "{{ postgresql_data_path }}:{{ postgresql_container_data_dir }}:z"
|
||||
- "{{ postgresql_pg_hba_conf_file }}:{{ postgresql_container_data_dir }}/pg_hba.conf:ro"
|
||||
- "{{ postgresql_pg_ident_conf_file }}:{{ postgresql_container_data_dir }}/pg_ident.conf:ro"
|
||||
- "{{ postgresql_container_passwd_file }}:/etc/passwd:ro"
|
||||
postgresql_container_merged_volumes: >-2
|
||||
{{ postgresql_container_base_volumes
|
||||
+ (postgresql_container_volumes | default([], true)) }}
|
||||
|
||||
# (Memory) performance tuning
|
||||
postgresql_container_memory: ~
|
||||
@ -47,4 +56,5 @@ postgresql_container_oom_kill: ~
|
||||
postgresql_container_oom_score_adj: ~
|
||||
postgresql_container_ulimits: ~
|
||||
|
||||
postgresql_container_passwd_file: "/etc/postgresql/{{ postgresql_major_version }}/passwd"
|
||||
postgresql_container_passwd_file: "{{ postgresql_config_path }}/passwd"
|
||||
postgresql_container_data_dir: "/var/lib/postgresql/data"
|
||||
|
@ -1,7 +1,7 @@
|
||||
---
|
||||
postgresql_user: postgresql
|
||||
postgresql_version: >-2
|
||||
{{ postgresql_version[postgres_major_version | string] }}
|
||||
{{ postgresql_versions[postgresql_major_version | string] }}
|
||||
postgresql_major_version: 16
|
||||
postgresql_versions:
|
||||
"17": "17.2"
|
||||
@ -14,12 +14,20 @@ postgresql_config_path: >-2
|
||||
postgresql_data_path: >-2
|
||||
/var/lib/postgresql/{{ postgresql_major_version }}
|
||||
postgresql_pg_ident_conf_file: >-2
|
||||
{{ postgresql_data_path }}/pg_ident.conf
|
||||
{{ postgresql_config_path }}/pg_ident.conf
|
||||
postgresql_pg_hba_conf_file: >-2
|
||||
{{ postgresql_data_path }}/pg_hba.conf
|
||||
{{ postgresql_config_path }}/pg_hba.conf
|
||||
postgresql_admin_role: "{{ postgresql_user }}"
|
||||
postgresql_admin_role_contype: local
|
||||
postgresql_admin_role_method: peer
|
||||
postgresql_admin_local_user: >-2
|
||||
{{ ansible_facts['user_id'] }}
|
||||
postgresql_admin_role_mapping_name: >-2
|
||||
{{ postgresql_admin_local_user }}_{{ postgresql_admin_role }}
|
||||
postgresql_admin_pg_ident_conf: >-2
|
||||
{{ postgresql_admin_role_mapping_name }}\t{{ postgresql_admin_local_user }}\t{{ postgresql_admin_role }}
|
||||
postgresql_admin_pg_hba_conf_options: >-2
|
||||
map={{ postgresql_admin_role_mapping_name }}
|
||||
postgresql_superuser_password: ~
|
||||
|
||||
postgresql_state: present
|
||||
|
@ -21,7 +21,7 @@
|
||||
|
||||
- name: Initialize database if empty
|
||||
ansible.builtin.include_tasks:
|
||||
file: "docker-initialize.yml"
|
||||
file: "initialize-docker.yml"
|
||||
when:
|
||||
- postgresql_state == 'present'
|
||||
|
||||
@ -33,6 +33,7 @@
|
||||
user: "{{ postgresql_container_user | default(omit, true) }}"
|
||||
ports: "{{ postgresql_container_ports | default(omit, true) }}"
|
||||
labels: "{{ postgresql_container_labels | default(omit, true) }}"
|
||||
volumes: "{{ postgresql_container_merged_volumes }}"
|
||||
recreate: "{{ postgresql_container_recreate | default(omit, true) }}"
|
||||
networks: "{{ postgresql_container_networks | default(omit, true) }}"
|
||||
etc_hosts: "{{ postgresql_container_etc_hosts | default(omit, true) }}"
|
||||
@ -44,5 +45,3 @@
|
||||
ulimits: "{{ postgresql_container_ulimits | default(omit, true) }}"
|
||||
restart_policy: "{{ postgresql_container_restart_policy | default(omit, true) }}"
|
||||
state: "{{ postgresql_container_state }}"
|
||||
|
||||
-
|
||||
|
@ -1,13 +1,26 @@
|
||||
---
|
||||
- name: Ensure container '{{ postgresql_container_name }}' is {{ postgresql_container_state }} to initialise the database
|
||||
community.docker.docker_container:
|
||||
name: "{{ postgresql_container_name }}"
|
||||
user: "{{ postgresql_container_user }}"
|
||||
image: "{{ postgresql_container_image }}"
|
||||
ports: "{{ postgresql_container_ports }}"
|
||||
env: >-2
|
||||
{{ postgresql_container_env | default({}, true)
|
||||
| combine({'POSTGRES_PASSWORD': postgresql_superuser_password}) }}
|
||||
user: "{{ postgresql_container_user | default(omit, true) }}"
|
||||
ports: "{{ postgresql_container_ports | default(omit, true) }}"
|
||||
labels: "{{ postgresql_container_labels | default(omit, true) }}"
|
||||
volumes: "{{ postgresql_container_merged_volumes }}"
|
||||
recreate: "{{ postgresql_container_recreate | default(omit, true) }}"
|
||||
networks: "{{ postgresql_container_networks | default(omit, true) }}"
|
||||
etc_hosts: "{{ postgresql_container_etc_hosts | default(omit, true) }}"
|
||||
state: started
|
||||
memory: "{{ postgresql_container_memory | default(omit, true) }}"
|
||||
memory_reservation: "{{ postgresql_container_memory_reservation | default(omit, true) }}"
|
||||
oom_killer: "{{ postgresql_container_oom_killer | default(omit, true) }}"
|
||||
oom_score_adj: "{{ postgresql_container_oom_score_adj | default(omit, true) }}"
|
||||
shm_size: "{{ postgresql_container_shm_size | default(omit, true) }}"
|
||||
ulimits: "{{ postgresql_container_ulimits | default(omit, true) }}"
|
||||
restart_policy: "{{ postgresql_container_restart_policy | default(omit, true) }}"
|
||||
state: "{{ postgresql_container_state }}"
|
||||
register: postgresql_container_info
|
||||
|
||||
- name: Wait for container startup
|
||||
@ -15,7 +28,7 @@
|
||||
- name: Wait for container startup (socket)
|
||||
ansible.builtin.wait_for:
|
||||
path: "{{ postgresql_config_unix_socket_directories | first }}.s.PGSQL.{{ postgresql_config_port }}"
|
||||
when: "{{ postgresql_config_connect_socket }}"
|
||||
when: "postgresql_config_connect_socket | bool"
|
||||
- name: Wait for container startup (port)
|
||||
ansible.builtin.wait_for:
|
||||
host: >-2
|
||||
@ -24,7 +37,7 @@
|
||||
postgresql_config_listen_addresses | first
|
||||
) }}
|
||||
port: "{{ postgresql_config_port }}"
|
||||
when: "{{ not postgresql_config_connect_socket }}"
|
||||
when: "not postgresql_config_connect_socket | bool"
|
||||
vars:
|
||||
pg_addresses: "{{ postgresql_config_listen_addresses | join(',') }}"
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user