2014-12-02 03:57:40 +01:00
|
|
|
- include_vars: '{{ item }}'
|
|
|
|
with_first_found:
|
|
|
|
- files:
|
|
|
|
- '{{ ansible_distribution }}-{{ ansible_distribution_major_version }}.yml'
|
|
|
|
- '{{ ansible_distribution }}-{{ ansible_distribution_version }}.yml'
|
|
|
|
- '{{ ansible_os_family }}.yml'
|
|
|
|
- 'default.yml'
|
|
|
|
paths: '../vars'
|
|
|
|
|
|
|
|
# Make sure we start fresh
|
|
|
|
- name: remove rpm dependencies for postgresql test
|
2015-10-23 09:27:09 +02:00
|
|
|
package: name={{ postgresql_package_item }} state=absent
|
2016-02-08 19:13:15 +01:00
|
|
|
with_items: "{{postgresql_packages}}"
|
2015-10-23 09:27:09 +02:00
|
|
|
loop_control:
|
|
|
|
loop_var: postgresql_package_item
|
2015-12-20 17:06:26 +01:00
|
|
|
when: ansible_os_family == "RedHat"
|
2014-12-02 03:57:40 +01:00
|
|
|
|
|
|
|
- name: remove dpkg dependencies for postgresql test
|
2015-10-23 09:27:09 +02:00
|
|
|
apt: name={{ postgresql_package_item }} state=absent
|
2016-02-08 19:13:15 +01:00
|
|
|
with_items: "{{postgresql_packages}}"
|
2015-10-23 09:27:09 +02:00
|
|
|
loop_control:
|
|
|
|
loop_var: postgresql_package_item
|
2014-12-02 03:57:40 +01:00
|
|
|
when: ansible_pkg_mgr == 'apt'
|
|
|
|
|
|
|
|
- name: remove old db (red hat)
|
|
|
|
command: rm -rf "{{ pg_dir }}"
|
|
|
|
ignore_errors: True
|
|
|
|
when: ansible_os_family == "RedHat"
|
|
|
|
|
|
|
|
# Theoretically, pg_dropcluster should work but it doesn't so rm files
|
|
|
|
- name: remove old db config (debian)
|
|
|
|
command: rm -rf /etc/postgresql
|
|
|
|
ignore_errors: True
|
|
|
|
when: ansible_os_family == "Debian"
|
|
|
|
|
|
|
|
- name: remove old db files (debian)
|
|
|
|
command: rm -rf /var/lib/postgresql
|
|
|
|
ignore_errors: True
|
|
|
|
when: ansible_os_family == "Debian"
|
|
|
|
|
|
|
|
- name: install rpm dependencies for postgresql test
|
2015-10-23 09:27:09 +02:00
|
|
|
package: name={{ postgresql_package_item }} state=latest
|
2016-02-08 19:13:15 +01:00
|
|
|
with_items: "{{postgresql_packages}}"
|
2015-10-23 09:27:09 +02:00
|
|
|
loop_control:
|
|
|
|
loop_var: postgresql_package_item
|
2015-12-20 17:06:26 +01:00
|
|
|
when: ansible_os_family == "RedHat"
|
2014-12-02 03:57:40 +01:00
|
|
|
|
|
|
|
- name: install dpkg dependencies for postgresql test
|
2015-10-23 09:27:09 +02:00
|
|
|
apt: name={{ postgresql_package_item }} state=latest
|
2016-02-08 19:13:15 +01:00
|
|
|
with_items: "{{postgresql_packages}}"
|
2015-10-23 09:27:09 +02:00
|
|
|
loop_control:
|
|
|
|
loop_var: postgresql_package_item
|
2014-12-02 03:57:40 +01:00
|
|
|
when: ansible_pkg_mgr == 'apt'
|
|
|
|
|
2016-04-23 22:43:11 +02:00
|
|
|
- name: Initialize postgres (RedHat systemd)
|
2014-12-02 03:57:40 +01:00
|
|
|
command: postgresql-setup initdb
|
|
|
|
when: ansible_distribution == "Fedora" or (ansible_os_family == "RedHat" and ansible_distribution_major_version|int >= 7)
|
|
|
|
|
2016-04-23 22:43:11 +02:00
|
|
|
- name: Initialize postgres (RedHat sysv)
|
2014-12-02 03:57:40 +01:00
|
|
|
command: /sbin/service postgresql initdb
|
|
|
|
when: ansible_os_family == "RedHat" and ansible_distribution_major_version|int <= 6
|
|
|
|
|
2016-04-23 22:43:11 +02:00
|
|
|
- name: Iniitalize postgres (Debian)
|
2014-12-03 16:37:51 +01:00
|
|
|
command: /usr/bin/pg_createcluster {{ pg_ver }} main
|
|
|
|
# Sometimes package install creates the db cluster, sometimes this step is needed
|
|
|
|
ignore_errors: True
|
|
|
|
when: ansible_os_family == 'Debian'
|
2014-12-02 03:57:40 +01:00
|
|
|
|
|
|
|
- name: Copy pg_hba into place
|
|
|
|
copy: src=pg_hba.conf dest="{{ pg_hba_location }}" owner="postgres" group="root" mode="0644"
|
|
|
|
|
2014-12-10 23:25:40 +01:00
|
|
|
- name: Generate pt_BR locale (Debian)
|
2014-12-02 03:57:40 +01:00
|
|
|
command: locale-gen pt_BR
|
|
|
|
when: ansible_os_family == 'Debian'
|
|
|
|
|
2014-12-10 23:25:40 +01:00
|
|
|
- name: Generate es_MX locale (Debian)
|
2014-12-02 03:57:40 +01:00
|
|
|
command: locale-gen es_MX
|
|
|
|
when: ansible_os_family == 'Debian'
|
|
|
|
|
2014-12-10 23:25:40 +01:00
|
|
|
- name: Generate pt_BR locale (Red Hat)
|
2014-12-10 23:51:02 +01:00
|
|
|
command: localedef -f ISO-8859-1 -i pt_BR pt_BR
|
2014-12-10 23:25:40 +01:00
|
|
|
when: ansible_os_family == 'RedHat'
|
|
|
|
|
|
|
|
- name: Generate es_MX locale (Red Hat)
|
2014-12-10 23:51:02 +01:00
|
|
|
command: localedef -f ISO-8859-1 -i es_MX es_MX
|
2014-12-10 23:25:40 +01:00
|
|
|
when: ansible_os_family == 'RedHat'
|
|
|
|
|
2014-12-02 03:57:40 +01:00
|
|
|
- name: restart postgresql service
|
|
|
|
service: name={{ postgresql_service }} state=restarted
|