mirror of
https://gitea.0xace.cc/ansible-galaxy/pgbouncer.git
synced 2024-11-24 20:56:40 +00:00
split variables for RedHat and Debain os family
This commit is contained in:
parent
7940184553
commit
9668298b45
@ -1 +1,7 @@
|
|||||||
Setup pgbouncer for RHEL8
|
Setup pgbouncer
|
||||||
|
|
||||||
|
Tested with OS:
|
||||||
|
- AlmaLinux 8/9
|
||||||
|
- Debian 11
|
||||||
|
- Ubuntu 20.04/22.04
|
||||||
|
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
pgbouncer_postgresql_major_version: "15"
|
||||||
pgbouncer_conf_dir: "/etc/pgbouncer"
|
pgbouncer_conf_dir: "/etc/pgbouncer"
|
||||||
pgbouncer_conf_name: "pgbouncer.ini"
|
pgbouncer_conf_name: "pgbouncer.ini"
|
||||||
pgbouncer_log_dir: "/var/log/pgbouncer"
|
pgbouncer_log_dir: "/var/log/pgbouncer"
|
||||||
@ -14,7 +15,7 @@ pgbouncer_default_pool_mode: "session"
|
|||||||
pgbouncer_ignore_startup_parameters: "extra_float_digits,geqo"
|
pgbouncer_ignore_startup_parameters: "extra_float_digits,geqo"
|
||||||
pgbouncer_auth_type: "hba"
|
pgbouncer_auth_type: "hba"
|
||||||
pgbouncer_auth_user: "postgres"
|
pgbouncer_auth_user: "postgres"
|
||||||
pgbouncer_auth_hba_file: "{{ pgbouncer_postgresql_home_dir }}/{{ pgbouncer_postgresql_major_version }}/data/pg_hba.conf"
|
pgbouncer_auth_hba_file: "{{ pgbouncer_postgresql_config_cluster_dir }}/pg_hba.conf"
|
||||||
pgbouncer_auth_file_name: "userlist.txt"
|
pgbouncer_auth_file_name: "userlist.txt"
|
||||||
pgbouncer_auth_file: "{{ pgbouncer_conf_dir }}/{{ pgbouncer_auth_file_name }}"
|
pgbouncer_auth_file: "{{ pgbouncer_conf_dir }}/{{ pgbouncer_auth_file_name }}"
|
||||||
pgbouncer_admin_users: "postgres"
|
pgbouncer_admin_users: "postgres"
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
---
|
---
|
||||||
|
|
||||||
- name: Restart pgbouncer service
|
- name: Restart pgbouncer service
|
||||||
systemd:
|
systemd:
|
||||||
daemon_reload: true
|
daemon_reload: true
|
||||||
@ -18,5 +17,3 @@
|
|||||||
delay: 5
|
delay: 5
|
||||||
ignore_errors: false
|
ignore_errors: false
|
||||||
listen: "restart pgbouncer"
|
listen: "restart pgbouncer"
|
||||||
|
|
||||||
...
|
|
||||||
|
@ -1,50 +1,48 @@
|
|||||||
---
|
---
|
||||||
# yamllint disable rule:line-length
|
|
||||||
|
|
||||||
- name: Make sure handlers are flushed immediately
|
- name: Make sure handlers are flushed immediately
|
||||||
meta: flush_handlers
|
meta: flush_handlers
|
||||||
|
|
||||||
|
- name: Gather packages
|
||||||
|
package_facts:
|
||||||
|
manager: auto
|
||||||
|
|
||||||
- name: Load a variable file based on the OS type
|
- name: Load a variable file based on the OS type
|
||||||
include_vars: "{{ lookup('first_found', params) }}"
|
include_vars: "{{ lookup('first_found', params) }}"
|
||||||
vars:
|
vars:
|
||||||
params:
|
params:
|
||||||
files:
|
files:
|
||||||
|
- "{{ ansible_facts['distribution'] }}-{{ ansible_facts['distribution_major_version'] }}.yaml"
|
||||||
|
- "{{ ansible_facts['distribution'] }}-{{ ansible_facts['distribution_version'] }}.yaml"
|
||||||
|
- "{{ ansible_facts['os_family'] }}-{{ ansible_facts['distribution_major_version'] }}.yaml"
|
||||||
|
- "{{ ansible_facts['os_family'] }}-{{ ansible_facts['distribution_version'] }}.yaml"
|
||||||
- "{{ ansible_facts['distribution'] }}.yaml"
|
- "{{ ansible_facts['distribution'] }}.yaml"
|
||||||
- "{{ ansible_facts['os_family'] }}.yaml"
|
- "{{ ansible_facts['os_family'] }}.yaml"
|
||||||
paths:
|
paths:
|
||||||
- "vars"
|
- "vars"
|
||||||
tags: pgbouncer_vars
|
tags: pgbouncer_vars
|
||||||
|
|
||||||
- name: "Gather packages"
|
|
||||||
package_facts:
|
|
||||||
manager: auto
|
|
||||||
|
|
||||||
- name: "Set fact about PostgreSQL package"
|
- name: "Set fact about PostgreSQL package"
|
||||||
set_fact:
|
set_fact:
|
||||||
pgbouncer_postgresql_package_name: "{{ ansible_facts.packages | list | select('match', pgbouncer_postgresql_package_name_regex) | first }}"
|
pgbouncer_postgresql_package_name: "{{ ansible_facts.packages | list | select('match', pgbouncer_postgresql_package_name_regex) | first }}"
|
||||||
|
|
||||||
- name: "Get PostgreSQL major and minor versions"
|
- name: "Get PostgreSQL major version"
|
||||||
set_fact:
|
set_fact:
|
||||||
pgbouncer_postgresql_major_version: "{{ ansible_facts.packages[pgbouncer_postgresql_package_name][0]['version'] | split('.') | first }}"
|
pgbouncer_postgresql_major_version: "{{ ansible_facts.packages[pgbouncer_postgresql_package_name][0]['version'] | split('.') | first }}"
|
||||||
pgbouncer_postgresql_minor_version: "{{ ansible_facts.packages[pgbouncer_postgresql_package_name][0]['version'] | split('.') | last }}"
|
pgbouncer_postgresql_minor_version: "{{ ansible_facts.packages[pgbouncer_postgresql_package_name][0]['version'] | split('.') | last }}"
|
||||||
|
|
||||||
|
- name: Mask pgbouncer before install
|
||||||
|
systemd:
|
||||||
|
name: pgbouncer
|
||||||
|
masked: yes
|
||||||
|
when:
|
||||||
|
- ansible_os_family == "Debian"
|
||||||
|
- "'pgbouncer' not in ansible_facts.packages"
|
||||||
|
tags: pgbouncer_mask, pgbouncer
|
||||||
|
|
||||||
- name: Install pgbouncer package
|
- name: Install pgbouncer package
|
||||||
package:
|
package:
|
||||||
name: pgbouncer
|
name: pgbouncer
|
||||||
environment: "{{ proxy_env | default({}) }}"
|
environment: "{{ proxy_env | default({}) }}"
|
||||||
when: ansible_os_family == "Debian" or
|
|
||||||
(ansible_os_family == "RedHat" and
|
|
||||||
ansible_distribution_major_version == '7')
|
|
||||||
tags: pgbouncer_install, pgbouncer
|
|
||||||
|
|
||||||
# RHEL 8
|
|
||||||
- name: Install pgbouncer package
|
|
||||||
dnf:
|
|
||||||
name: pgbouncer
|
|
||||||
disablerepo: AppStream
|
|
||||||
environment: "{{ proxy_env | default({}) }}"
|
|
||||||
when: ansible_os_family == "RedHat" and
|
|
||||||
ansible_distribution_major_version >= '8'
|
|
||||||
tags: pgbouncer_install, pgbouncer
|
tags: pgbouncer_install, pgbouncer
|
||||||
|
|
||||||
- name: Ensure config directory "{{ pgbouncer_conf_dir }}" exist
|
- name: Ensure config directory "{{ pgbouncer_conf_dir }}" exist
|
||||||
@ -56,14 +54,6 @@
|
|||||||
mode: 0750
|
mode: 0750
|
||||||
tags: pgbouncer_conf, pgbouncer
|
tags: pgbouncer_conf, pgbouncer
|
||||||
|
|
||||||
- name: Stop and disable standard init script
|
|
||||||
service:
|
|
||||||
name: pgbouncer
|
|
||||||
state: stopped
|
|
||||||
enabled: false
|
|
||||||
when: ansible_os_family == "Debian"
|
|
||||||
tags: pgbouncer_service, pgbouncer
|
|
||||||
|
|
||||||
- name: Add pgbouncer systemd unit user and group override
|
- name: Add pgbouncer systemd unit user and group override
|
||||||
block:
|
block:
|
||||||
- name: Ensure override dir for pgbouncer exists
|
- name: Ensure override dir for pgbouncer exists
|
||||||
@ -159,3 +149,4 @@
|
|||||||
masked: no
|
masked: no
|
||||||
register: pgbouncer_enable_and_start
|
register: pgbouncer_enable_and_start
|
||||||
tags: pgbouncer, pgbouncer_start
|
tags: pgbouncer, pgbouncer_start
|
||||||
|
|
||||||
|
@ -1,2 +1,8 @@
|
|||||||
|
pgbouncer_postgresql_config_dir: "/etc/postgresql"
|
||||||
|
pgbouncer_postgresql_config_cluster_dir: "{{ pgbouncer_postgresql_config_dir }}/{{ pgbouncer_postgresql_major_version }}/{{ pgbouncer_postgresql_cluster_name }}"
|
||||||
pgbouncer_postgresql_home_dir: "/var/lib/postgresql"
|
pgbouncer_postgresql_home_dir: "/var/lib/postgresql"
|
||||||
|
pgbouncer_postgresql_data_dir: "{{ pgbouncer_postgresql_home_dir }}/{{ pgbouncer_postgresql_major_version }}/{{ pgbouncer_postgresql_cluster_name }}"
|
||||||
|
pgbouncer_postgresql_ssl_path: "{{ pgbouncer_postgresql_config_dir }}/{{ pgbouncer_postgresql_major_version }}/{{ pgbouncer_postgresql_cluster_name }}"
|
||||||
|
pgbouncer_postgresql_cluster_name: "main"
|
||||||
|
|
||||||
pgbouncer_postgresql_package_name_regex: 'postgresql-.[{{ pgbouncer_postgresql_supported_versions | join(",") }}]'
|
pgbouncer_postgresql_package_name_regex: 'postgresql-.[{{ pgbouncer_postgresql_supported_versions | join(",") }}]'
|
||||||
|
@ -1,2 +1,7 @@
|
|||||||
pgbouncer_postgresql_home_dir: "/var/lib/pgsql"
|
pgbouncer_postgresql_home_dir: "/var/lib/pgsql"
|
||||||
|
pgbouncer_postgresql_data_dir: "{{ pgbouncer_postgresql_home_dir }}/{{ pgbouncer_postgresql_major_version }}/data"
|
||||||
|
pgbouncer_postgresql_ssl_path: "{{ pgbouncer_postgresql_home_dir }}/{{ pgbouncer_postgresql_major_version }}"
|
||||||
|
pgbouncer_postgresql_config_dir: "{{ pgbouncer_postgresql_data_dir }}"
|
||||||
|
pgbouncer_postgresql_config_cluster_dir: "{{ pgbouncer_postgresql_data_dir }}"
|
||||||
|
|
||||||
pgbouncer_postgresql_package_name_regex: 'postgresql.[{{ pgbouncer_postgresql_supported_versions | join(",") }}]-server'
|
pgbouncer_postgresql_package_name_regex: 'postgresql.[{{ pgbouncer_postgresql_supported_versions | join(",") }}]-server'
|
||||||
|
5
vars/main.yaml
Normal file
5
vars/main.yaml
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
postgresql_major_version: "{{ postgresql_version | split('.') | first }}"
|
||||||
|
postgresql_minor_version: "{{ postgresql_version | split('.') | last }}"
|
||||||
|
postgresql_system_locale: "en_US.UTF-8"
|
||||||
|
postgresql_system_language: "{{ postgresql_system_locale }}"
|
||||||
|
postgresql_system_override_dir: "/etc/systemd/system/postgresql-{{ postgresql_major_version }}.service.d"
|
Loading…
Reference in New Issue
Block a user