blob: 48f9211e1b4c8aaba8c2fcebee2bbf8a8a23d329 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
|
- 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
package: name={{ item }} state=absent
with_items: "{{postgresql_packages}}"
when: ansible_os_family == "RedHat"
- name: remove dpkg dependencies for postgresql test
apt: name={{ item }} state=absent
with_items: "{{postgresql_packages}}"
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
package: name={{ item }} state=latest
with_items: "{{postgresql_packages}}"
when: ansible_os_family == "RedHat"
- name: install dpkg dependencies for postgresql test
apt: name={{ item }} state=latest
with_items: "{{postgresql_packages}}"
when: ansible_pkg_mgr == 'apt'
- name: Initialize postgres (systemd)
command: postgresql-setup initdb
when: ansible_distribution == "Fedora" or (ansible_os_family == "RedHat" and ansible_distribution_major_version|int >= 7)
- name: Initialize postgres (sysv)
command: /sbin/service postgresql initdb
when: ansible_os_family == "RedHat" and ansible_distribution_major_version|int <= 6
- name: Iniitalize postgres (upstart)
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'
- name: Copy pg_hba into place
copy: src=pg_hba.conf dest="{{ pg_hba_location }}" owner="postgres" group="root" mode="0644"
- name: Generate pt_BR locale (Debian)
command: locale-gen pt_BR
when: ansible_os_family == 'Debian'
- name: Generate es_MX locale (Debian)
command: locale-gen es_MX
when: ansible_os_family == 'Debian'
- name: Generate pt_BR locale (Red Hat)
command: localedef -f ISO-8859-1 -i pt_BR pt_BR
when: ansible_os_family == 'RedHat'
- name: Generate es_MX locale (Red Hat)
command: localedef -f ISO-8859-1 -i es_MX es_MX
when: ansible_os_family == 'RedHat'
- name: restart postgresql service
service: name={{ postgresql_service }} state=restarted
|