Process - Setup Postgres Server 1.1

1 Process

DescriptionThe process setup_pgserver installs a simple PostgreSQL-server, without any high-availabilty features. It can be used by IOM application-servers.
Example: setup postgresql server
ANSIBLE_LIBRARY=<path to Ansible4IOM>/modules/ ANSIBLE_ROLES_PATH=<path to Ansible4IOM>/roles/ ansible-playbook -i <path to inventory file>/inventory <path to Ansible4IOM>/processes/setup_pgserver.yml

1.1 Steps

The process consists of the following steps:

  1. pgrepo_install
    1. Install PostgreSQL repository.
  2. pgclient_install
    1. Install PG client yum package.
  3. pgserver_install
    1. Stop/disable PostgreSQL service.
    2. Install yum packages.
    3. Initialize PostgreSQL server.
  4. pgserver_configure
    1. Stop/disable PostgreSQL service.
    2. Install initial pg_hba.conf in order to allow setting superusers password.
    3. Set default values in postgresql.conf.
    4. Start/enable service (wait for DB to get ready).
    5. Update superusers password.
    6. Install productive pg_hba.conf in order to restrict access as much as possible.
    7. Run post_pgserver_configuration_hook.
    8. Restart service to apply changes.

1.2 Background Information

The process setup_pgserver installs a PostgreSQL server. Primarily the process is controlled by variables defined in roles/pgserver_config/defaults. Please have a look into the according file to get information about which variables are available.

Additionally, the process setup_pgserver executes hook post_pgserver_configuration_hook, which allows custom configuration changes of PostgreSQL-server besides predefined variables.

To use a server installed this way, a database account suitable for IOM has to be created. The creation of the account is covered by Process - Setup or Reconfigure Database Account.

2 Examples

2.1 Use a Custom Data Directory

The data directory is defined by variable PGSERVER_DATA at roles/pgserver_config/defaults. Add this variable to the inventory and give it a new value. Also see Concept - Ansible4IOM Server Configuration Management 1.0 - 1.1.

inventory file: change setting of variable PGSERVER_DATA
...
[all:vars]
PGSERVER_DATA="/ha-raid/pg-data"
...

The according directory can be created before running the setup process.

Now the process setup_pgserver can be executed.

Example: setup postgresql server
ANSIBLE_LIBRARY=<path to Ansible4IOM>/modules/ ANSIBLE_ROLES_PATH=<path to Ansible4IOM>/roles/ ansible-playbook -i <path to inventory file> <path to Ansible4IOM>/processes/setup_pgserver.yml

2.2 Use a Custom Setting for max_connections in postgresql.conf

To set database server settings besides predefined variables, the hook post_pgserver_configuration_hook has to be implemented. Depending on the scope of the hook (project or installation), the file post_pgserver_configuration_hook.yml has to be stored in the directory global_hooks or installation_hooks. Also see Concept - Ansible4IOM Server Configuration Management 1.0 - 1.1.

Note

It is important to use variables PGSERVER_DATA and PGServerOSUser (see roles/pgserver_config/defaults) for a robust implementation of the hook.
post_pgserver_configuration_hook.yml
- name: update postgreSQL configuration
  ini_file:
    dest: "{{PGSERVER_DATA}}/postgresql.conf"
    section: ""
    option: "{{item.option}}"
    value: "{{item.value}}"
  with_items:
    - { option: max_connections, value: 500 }
  become: true
  become_user: "{{PGServerOSUser}}"

Now the process setup_pgserver can be executed.

Example: setup postgresql server
ANSIBLE_LIBRARY=<path to Ansible4IOM>/modules/ ANSIBLE_ROLES_PATH=<path to Ansible4IOM>/roles/ ansible-playbook -i <path to inventory file> <path to Ansible4IOM>/processes/setup_pgserver.yml

Disclaimer

The information provided in the Knowledge Base may not be applicable to all systems and situations. Intershop Communications will not be liable to any party for any direct or indirect damages resulting from the use of the Customer Support section of the Intershop Corporate Web site, including, without limitation, any lost profits, business interruption, loss of programs or other data on your information handling system.

Customer Support
Knowledge Base
Product Resources
Support Tickets