Run postgresql tests on FreeBSD. (#20676)

* Use vars for user, group and locale suffix.
* Switch tests from `es_MX` to `es_ES`.
* Enable postgresql tests on freebsd.
* Work-arounds for service restart on freebsd.
This commit is contained in:
Matt Clay 2017-01-25 18:45:28 -08:00 committed by GitHub
parent 5d5e5e25a2
commit 31d6b6ef67
6 changed files with 210 additions and 108 deletions

View file

@ -3,3 +3,9 @@ postgresql_service: postgresql
postgresql_packages:
- postgresql-server
- python-psycopg2
pg_user: postgres
pg_group: root
locale_latin_suffix:
locale_utf8_suffix:

View file

@ -2,7 +2,7 @@
# Database administrative login by UNIX sockets
# note: you may wish to restrict this further later
local all postgres trust
local all {{ pg_user }} trust
# TYPE DATABASE USER CIDR-ADDRESS METHOD
local all all md5

View file

@ -18,11 +18,21 @@
paths: '../vars'
# Make sure we start fresh
- name: stop postgresql service
service: name={{ postgresql_service }} state=stopped
ignore_errors: True
- name: remove old db (RedHat or Suse)
command: rm -rf "{{ pg_dir }}"
ignore_errors: True
when: ansible_os_family == "RedHat" or ansible_os_family == "Suse"
- name: remove old db (FreeBSD)
file:
path: "{{ pg_dir }}"
state: absent
when: ansible_os_family == "FreeBSD"
# Theoretically, pg_dropcluster should work but it doesn't so rm files
- name: remove old db config (debian)
command: rm -rf /etc/postgresql
@ -48,6 +58,17 @@
loop_var: postgresql_package_item
when: ansible_pkg_mgr == 'apt'
- name: install FreeBSD dependencies for postgresql test
pkgng: name={{ postgresql_package_item }} state=present
with_items: "{{postgresql_packages}}"
loop_control:
loop_var: postgresql_package_item
when: ansible_os_family == "FreeBSD"
- name: initialize postgres (FreeBSD)
command: /usr/local/etc/rc.d/postgresql oneinitdb
when: ansible_os_family == "FreeBSD"
- name: Initialize postgres (RedHat systemd)
command: postgresql-setup initdb
when: ansible_distribution == "Fedora" or (ansible_os_family == "RedHat" and ansible_distribution_major_version|int >= 7)
@ -67,14 +88,19 @@
when: ansible_os_family == 'Suse'
- name: Copy pg_hba into place
copy: src=pg_hba.conf dest="{{ pg_hba_location }}" owner="postgres" group="root" mode="0644"
template:
src: files/pg_hba.conf
dest: "{{ pg_hba_location }}"
owner: "{{ pg_user }}"
group: "{{ pg_group }}"
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
- name: Generate es_ES locale (Debian)
command: locale-gen es_ES
when: ansible_os_family == 'Debian'
- name: install i18ndata
@ -85,9 +111,19 @@
command: localedef -f ISO-8859-1 -i pt_BR pt_BR
when: ansible_os_family == "RedHat" or ansible_os_family == "Suse"
- name: Generate es_MX locale (Red Hat)
command: localedef -f ISO-8859-1 -i es_MX es_MX
- name: Generate es_ES locale (Red Hat)
command: localedef -f ISO-8859-1 -i es_ES es_ES
when: ansible_os_family == "RedHat" or ansible_os_family == "Suse"
- name: enable postgresql service (FreeBSD)
lineinfile:
path: /etc/rc.conf
line: 'postgresql_enable="YES"'
when: ansible_os_family == "FreeBSD"
- name: start postgresql service
# work-around for issue on FreeBSD where service won't restart if currently stopped
service: name={{ postgresql_service }} state=started
- name: restart postgresql service
service: name={{ postgresql_service }} state=restarted

View file

@ -0,0 +1,14 @@
postgresql_service: "postgresql"
postgresql_packages:
- "postgresql93-server"
- "py27-psycopg2"
pg_hba_location: "/usr/local/pgsql/data/pg_hba.conf"
pg_dir: "/usr/local/pgsql/data"
pg_ver: 9.3
pg_user: pgsql
pg_group: pgsql
locale_latin_suffix: .ISO8859-1
locale_utf8_suffix: .UTF-8