2017-10-27 14:20:21 +00:00
|
|
|
- name: Install PostgreSQL packages
|
2017-12-08 08:53:07 +00:00
|
|
|
package:
|
|
|
|
name: "{{ item }}"
|
|
|
|
state: present
|
2017-05-27 18:09:50 +00:00
|
|
|
with_items:
|
|
|
|
- postgresql
|
|
|
|
tags:
|
|
|
|
- download
|
|
|
|
|
2017-12-08 08:53:07 +00:00
|
|
|
- name: Install postgresql-client (debuntu)
|
|
|
|
package:
|
|
|
|
name: postgresql-client
|
2017-05-27 23:10:45 +00:00
|
|
|
when: is_debuntu
|
2017-05-27 18:09:50 +00:00
|
|
|
tags:
|
|
|
|
- download
|
|
|
|
|
2017-12-08 08:53:07 +00:00
|
|
|
- name: Install postgresql-server (OS's other than debuntu)
|
|
|
|
package:
|
|
|
|
name: postgresql-server
|
2017-05-27 23:10:45 +00:00
|
|
|
when: not is_debuntu
|
2017-05-27 18:09:50 +00:00
|
|
|
tags:
|
|
|
|
- download
|
|
|
|
|
2017-06-28 02:53:13 +00:00
|
|
|
- name: Create postgresql-iiab systemd service
|
2017-12-08 08:53:07 +00:00
|
|
|
template:
|
|
|
|
src: postgresql-iiab.service
|
|
|
|
dest: /etc/systemd/system/postgresql-iiab.service
|
|
|
|
owner: root
|
|
|
|
group: root
|
|
|
|
mode: 0644
|
2017-05-27 18:09:50 +00:00
|
|
|
|
|
|
|
- name: Create postgres data directory
|
2017-12-08 08:53:07 +00:00
|
|
|
file:
|
|
|
|
path: /library/pgsql-iiab
|
|
|
|
owner: postgres
|
|
|
|
group: postgres
|
|
|
|
mode: 0700
|
|
|
|
state: directory
|
2017-05-27 18:09:50 +00:00
|
|
|
|
2017-12-08 08:53:07 +00:00
|
|
|
- name: Make sure that the en_US locale is enabled (debuntu)
|
|
|
|
lineinfile:
|
|
|
|
dest: /etc/locale.gen
|
|
|
|
line: "{{ postgresql_locale }} UTF-8"
|
2017-05-27 23:10:45 +00:00
|
|
|
when: is_debuntu
|
2017-05-27 18:09:50 +00:00
|
|
|
|
2017-12-08 08:53:07 +00:00
|
|
|
- name: Generate the selected locales (debuntu)
|
2017-05-27 18:09:50 +00:00
|
|
|
command: /usr/sbin/locale-gen
|
2017-05-27 23:10:45 +00:00
|
|
|
when: is_debuntu
|
2017-05-27 18:09:50 +00:00
|
|
|
|
2017-12-08 08:53:07 +00:00
|
|
|
- name: Initialize the postgres db (debuntu)
|
|
|
|
command: su - postgres -c "/usr/lib/postgresql/{{ postgresql_version }}/bin/initdb -E 'UTF-8' --locale={{ postgresql_locale }} -D /library/pgsql-iiab"
|
|
|
|
args:
|
|
|
|
creates: /library/pgsql-iiab/pg_hba.conf
|
2017-11-10 09:14:25 +00:00
|
|
|
when: is_debuntu
|
2017-05-27 23:10:45 +00:00
|
|
|
|
2017-12-08 08:53:07 +00:00
|
|
|
- name: Initialize the postgres db (OS's other than debuntu)
|
|
|
|
command: su - postgres -c "/usr/bin/initdb -E 'UTF-8' --lc-collate={{ postgresql_locale }} --lc-ctype={{ postgresql_locale }} -D /library/pgsql-iiab"
|
|
|
|
args:
|
|
|
|
creates: /library/pgsql-iiab/pg_hba.conf
|
2017-05-27 23:10:45 +00:00
|
|
|
when: not is_debuntu
|
2017-05-27 18:09:50 +00:00
|
|
|
|
2017-10-27 14:20:21 +00:00
|
|
|
- name: Configure PostgreSQL
|
2017-12-08 08:53:07 +00:00
|
|
|
template:
|
|
|
|
backup: yes
|
|
|
|
src: postgresql.conf.j2
|
|
|
|
dest: /library/pgsql-iiab/postgresql.conf
|
|
|
|
owner: postgres
|
|
|
|
group: postgres
|
|
|
|
mode: 0640
|
2017-05-27 18:09:50 +00:00
|
|
|
|
2017-12-08 08:53:07 +00:00
|
|
|
- name: Stop postgresql service (debuntu)
|
2017-10-27 03:58:56 +00:00
|
|
|
command: "/etc/init.d/postgresql stop"
|
|
|
|
ignore_errors: True
|
|
|
|
when: postgresql_install and is_debuntu
|
|
|
|
|
2017-05-27 18:09:50 +00:00
|
|
|
- name: Stop and disable stock postgresql service
|
2017-12-08 08:53:07 +00:00
|
|
|
service:
|
|
|
|
name: postgresql
|
|
|
|
state: stopped
|
|
|
|
enabled: no
|
2017-05-27 18:09:50 +00:00
|
|
|
|
2017-06-28 02:53:13 +00:00
|
|
|
- name: Start and enable postgresql-iiab service
|
2017-12-08 08:53:07 +00:00
|
|
|
service:
|
|
|
|
name: postgresql-iiab
|
|
|
|
state: started
|
|
|
|
enabled: yes
|
2017-05-27 18:09:50 +00:00
|
|
|
when: postgresql_enabled
|
|
|
|
|
2017-11-10 09:14:25 +00:00
|
|
|
- name: Stop and disable postgresql-iiab service if not postgresql_enabled
|
2017-12-08 08:53:07 +00:00
|
|
|
service:
|
|
|
|
name: postgresql-iiab
|
|
|
|
state: stopped
|
|
|
|
enabled: no
|
2017-10-27 03:58:56 +00:00
|
|
|
when: not postgresql_enabled
|
|
|
|
|
2017-12-08 08:53:07 +00:00
|
|
|
- name: Add 'postgresql' to list of services at /etc/iiab/iiab.ini
|
|
|
|
ini_file:
|
|
|
|
dest: "{{ service_filelist }}"
|
|
|
|
section: postgresql
|
|
|
|
option: "{{ item.option }}"
|
|
|
|
value: "{{ item.value }}"
|
2017-05-27 18:09:50 +00:00
|
|
|
with_items:
|
|
|
|
- option: name
|
2017-12-08 10:38:26 +00:00
|
|
|
value: PostgreSQL
|
2017-05-27 18:09:50 +00:00
|
|
|
- option: description
|
|
|
|
value: '"PostgreSQL is a powerful, open source object-relational database system."'
|
|
|
|
- option: installed
|
|
|
|
value: "{{ postgresql_install }}"
|
|
|
|
- option: enabled
|
|
|
|
value: "{{ postgresql_enabled }}"
|