PostgreSQL Integration test suite: improvements (#23631)

* PostgreSQL tests: use package module
* PostgreSQL tests: use ansible_service_mgr in order to test init system
* PostgreSQL tests: fix a typo
* PostgreSQL tests: install only required packages
* PostgreSQL tests: use role default value when unchanged
pull/24092/head
Pilou 8 years ago committed by Matt Clay
parent 9f56f87770
commit bf5d87af07

@ -44,26 +44,11 @@
ignore_errors: True ignore_errors: True
when: ansible_os_family == "Debian" when: ansible_os_family == "Debian"
- name: install rpm dependencies for postgresql test - name: install dependencies for postgresql test
package: name={{ postgresql_package_item }} state=latest package: name={{ postgresql_package_item }} state=present
with_items: "{{postgresql_packages}}" with_items: "{{ postgresql_packages }}"
loop_control: loop_control:
loop_var: postgresql_package_item loop_var: postgresql_package_item
when: ansible_os_family == "RedHat" or ansible_os_family == "Suse"
- name: install dpkg dependencies for postgresql test
apt: name={{ postgresql_package_item }} state=latest
with_items: "{{postgresql_packages}}"
loop_control:
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) - name: initialize postgres (FreeBSD)
command: /usr/local/etc/rc.d/postgresql oneinitdb command: /usr/local/etc/rc.d/postgresql oneinitdb
@ -71,13 +56,13 @@
- name: Initialize postgres (RedHat systemd) - name: Initialize postgres (RedHat systemd)
command: postgresql-setup initdb command: postgresql-setup initdb
when: ansible_distribution == "Fedora" or (ansible_os_family == "RedHat" and ansible_distribution_major_version|int >= 7) when: ansible_os_family == "RedHat" and ansible_service_mgr == "systemd"
- name: Initialize postgres (RedHat sysv) - name: Initialize postgres (RedHat sysv)
command: /sbin/service postgresql initdb command: /sbin/service postgresql initdb
when: ansible_os_family == "RedHat" and ansible_distribution_major_version|int <= 6 when: ansible_os_family == "RedHat" and ansible_service_mgr != "systemd"
- name: Iniitalize postgres (Debian) - name: Initialize postgres (Debian)
command: /usr/bin/pg_createcluster {{ pg_ver }} main command: /usr/bin/pg_createcluster {{ pg_ver }} main
# Sometimes package install creates the db cluster, sometimes this step is needed # Sometimes package install creates the db cluster, sometimes this step is needed
ignore_errors: True ignore_errors: True
@ -103,17 +88,37 @@
command: locale-gen es_ES command: locale-gen es_ES
when: ansible_os_family == 'Debian' when: ansible_os_family == 'Debian'
- name: install i18ndata # Suse: locales are installed by default (glibc-locale package).
zypper: name=glibc-i18ndata state=present # Fedora 23: locales are installed by default (glibc-common package)
when: ansible_os_family == 'Suse' # CentOS: all locales are installed by default (glibc-common package) but some
# RPM macros could prevent their installation (for example when using anaconda
- name: Generate pt_BR locale (Red Hat) # instLangs parameter).
command: localedef -f ISO-8859-1 -i pt_BR pt_BR
when: ansible_os_family == "RedHat" or ansible_os_family == "Suse"
- name: Generate es_ES locale (Red Hat) - block:
command: localedef -f ISO-8859-1 -i es_ES es_ES - name: Check if locales need to be generated (RedHat)
when: ansible_os_family == "RedHat" or ansible_os_family == "Suse" shell: "localedef --list-archive | grep -a -q '^{{ locale }}$'"
register: locale_present
ignore_errors: True
with_items:
- es_ES
- pt_BR
loop_control:
loop_var: locale
- name: Generate locale (RedHat)
command: 'localedef -f ISO-8859-1 -i {{ item.locale }} {{ item.locale }}'
when: item|failed
with_items: '{{ locale_present.results }}'
when: ansible_os_family == 'RedHat' and ansible_distribution != 'Fedora'
- name: Install glibc langpacks (Fedora >= 24)
package:
name: '{{ item }}'
state: 'latest'
with_items:
- glibc-langpack-es
- glibc-langpack-pt
when: ansible_distribution == 'Fedora' and ansible_distribution_major_version|int >= 24
- name: enable postgresql service (FreeBSD) - name: enable postgresql service (FreeBSD)
lineinfile: lineinfile:

@ -1,5 +1,3 @@
postgresql_service: "postgresql"
postgresql_packages: postgresql_packages:
- "postgresql" - "postgresql"
- "postgresql-common" - "postgresql-common"

@ -1,5 +1,3 @@
postgresql_service: "postgresql"
postgresql_packages: postgresql_packages:
- "postgresql93-server" - "postgresql93-server"
- "py27-psycopg2" - "py27-psycopg2"

@ -1,5 +1,3 @@
postgresql_service: "postgresql"
postgresql_packages: postgresql_packages:
- "postgresql" - "postgresql"
- "postgresql-common" - "postgresql-common"

@ -1,5 +1,3 @@
postgresql_service: "postgresql"
postgresql_packages: postgresql_packages:
- "postgresql" - "postgresql"
- "postgresql-common" - "postgresql-common"

@ -1,5 +1,3 @@
postgresql_service: "postgresql"
postgresql_packages: postgresql_packages:
- "postgresql" - "postgresql"
- "postgresql-common" - "postgresql-common"

@ -1,5 +1,3 @@
postgresql_service: "postgresql"
postgresql_packages: postgresql_packages:
- "postgresql" - "postgresql"
- "postgresql-common" - "postgresql-common"

@ -1,5 +1,3 @@
postgresql_service: "postgresql"
postgresql_packages: postgresql_packages:
- "postgresql-server" - "postgresql-server"
- "python-psycopg2" - "python-psycopg2"

Loading…
Cancel
Save