library/roles/postgresql: Add a playbook to install pgpool. Only the package right now.

This commit is contained in:
Andrea Dell'Amico 2016-03-01 18:01:41 +01:00
parent e7fa165d38
commit 59308c5e5c
5 changed files with 42 additions and 17 deletions

View File

@ -2,6 +2,9 @@
pg_use_postgresql_org_repo: True pg_use_postgresql_org_repo: True
psql_postgresql_install: True
postgresql_enabled: True
psql_pgpool_install: False
# 9.3 is the default version for Ubuntu trusty # 9.3 is the default version for Ubuntu trusty
# It is highly recommended to use the postgresql.org repositories # It is highly recommended to use the postgresql.org repositories
# #
@ -39,7 +42,6 @@ postgresql_pkgs:
- postgresql-client-'{{ psql_version }}' - postgresql-client-'{{ psql_version }}'
- pgtop - pgtop
psql_db_name: db_name psql_db_name: db_name
psql_db_user: db_user psql_db_user: db_user
psql_db_pwd: "We cannot save the password into the repository. Use another variable and change pgpass.j2 accordingly. Encrypt the file that contains the variable with ansible-vault" psql_db_pwd: "We cannot save the password into the repository. Use another variable and change pgpass.j2 accordingly. Encrypt the file that contains the variable with ansible-vault"
@ -72,3 +74,7 @@ pg_backup_use_nagios: "yes"
# Example of line needed to manage the db accesses (used by iptables too), without creating the db and the user. Useful, for example, to give someone access to the postgresql db # Example of line needed to manage the db accesses (used by iptables too), without creating the db and the user. Useful, for example, to give someone access to the postgresql db
#- { name: '{{ psql_db_name }}', user: '{{ psql_db_user }}', allowed_hosts: [ 'xxx.xxx.xxx.xxx/32', 'yyy.yyy.yyy.yyy/32' ] } #- { name: '{{ psql_db_name }}', user: '{{ psql_db_user }}', allowed_hosts: [ 'xxx.xxx.xxx.xxx/32', 'yyy.yyy.yyy.yyy/32' ] }
pgpool_pkgs:
- 'postgresql-{{ psql_version }}-pgpool2'

View File

@ -1,6 +1,8 @@
--- ---
- name: Restart postgresql - name: Restart postgresql
service: name=postgresql state=restarted service: name=postgresql state=restarted
when: postgresql_enabled
- name: Reload postgresql - name: Reload postgresql
service: name=postgresql state=reloaded service: name=postgresql state=reloaded
when: postgresql_enabled

View File

@ -2,15 +2,27 @@
- include: postgresql_org_repo.yml - include: postgresql_org_repo.yml
when: pg_use_postgresql_org_repo when: pg_use_postgresql_org_repo
- include: packages.yml - include: packages.yml
when: psql_postgresql_install
- include: postgis.yml - include: postgis.yml
when: postgres_install_gis_extensions when: postgres_install_gis_extensions
- include: postgresql-config.yml - include: postgresql-config.yml
when: psql_postgresql_install
- include: psql-kernel-sharedmem.yml - include: psql-kernel-sharedmem.yml
when: psql_set_shared_memory when:
- psql_postgresql_install
- psql_set_shared_memory
- include: configure-access.yml - include: configure-access.yml
when: psql_db_data is defined when:
- psql_postgresql_install
- psql_db_data is defined
- include: manage_pg_db.yml - include: manage_pg_db.yml
when: psql_db_data is defined when:
- psql_postgresql_install
- psql_db_data is defined
- include: postgresql-backup.yml - include: postgresql-backup.yml
when: psql_db_data is defined when:
- psql_postgresql_install
- psql_db_data is defined
- include: pgpool-ii.yml
when: psql_pgpool_install

View File

@ -1,24 +1,23 @@
--- ---
- name: install the postgresql packages - name: install the postgresql packages
apt: pkg={{ item }} state=installed apt: pkg={{ item }} state=installed
with_items: postgresql_pkgs with_items: '{{ postgresql_pkgs }}'
notify: notify: Restart postgresql
Restart postgresql tags: [ 'postgresql', 'postgres' ]
tags:
- postgresql
- postgres
- name: Install the packages that ansible needs to manage the postgresql users and databases - name: Install the packages that ansible needs to manage the postgresql users and databases
apt: pkg={{ item }} state=installed apt: pkg={{ item }} state=installed
with_items: with_items:
- python-psycopg2 - python-psycopg2
tags: tags: [ 'postgresql', 'postgres' ]
- postgresql
- postgres
- name: Ensure that the postgresql server is started - name: Ensure that the postgresql server is started
service: name=postgresql state=started enabled=yes service: name=postgresql state=started enabled=yes
tags: when: postgresql_enabled
- postgresql tags: [ 'postgresql', 'postgres' ]
- postgres
- name: Ensure that the postgresql server is stopped and disabled
service: name=postgresql state=stopped enabled=no
when: not postgresql_enabled
tags: [ 'postgresql', 'postgres' ]

View File

@ -0,0 +1,6 @@
---
- name: Install the pgpool package
apt: name={{ item }} state=installed
with_items: '{{ pgpool_pkgs }}'
tags: [ 'postgresql', 'pgpool' ]