From bf5d87af07d514242fb433b731e32a6c3378007d Mon Sep 17 00:00:00 2001 From: Pilou Date: Fri, 28 Apr 2017 03:09:40 +0200 Subject: [PATCH] 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 --- .../setup_postgresql_db/tasks/main.yml | 69 ++++++++++--------- .../setup_postgresql_db/vars/Debian-8.yml | 2 - .../setup_postgresql_db/vars/FreeBSD.yml | 2 - .../setup_postgresql_db/vars/Ubuntu-12.yml | 2 - .../setup_postgresql_db/vars/Ubuntu-14.yml | 2 - .../vars/Ubuntu-16-py3.yml | 2 - .../setup_postgresql_db/vars/Ubuntu-16.yml | 2 - .../setup_postgresql_db/vars/default.yml | 2 - 8 files changed, 37 insertions(+), 46 deletions(-) diff --git a/test/integration/targets/setup_postgresql_db/tasks/main.yml b/test/integration/targets/setup_postgresql_db/tasks/main.yml index 10f26c11aab..9f4321d0f55 100644 --- a/test/integration/targets/setup_postgresql_db/tasks/main.yml +++ b/test/integration/targets/setup_postgresql_db/tasks/main.yml @@ -44,26 +44,11 @@ ignore_errors: True when: ansible_os_family == "Debian" -- name: install rpm dependencies for postgresql test - package: name={{ postgresql_package_item }} state=latest - with_items: "{{postgresql_packages}}" +- name: install dependencies for postgresql test + package: name={{ postgresql_package_item }} state=present + with_items: "{{ postgresql_packages }}" loop_control: 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) command: /usr/local/etc/rc.d/postgresql oneinitdb @@ -71,13 +56,13 @@ - 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) + when: ansible_os_family == "RedHat" and ansible_service_mgr == "systemd" - name: Initialize postgres (RedHat sysv) 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 # Sometimes package install creates the db cluster, sometimes this step is needed ignore_errors: True @@ -103,17 +88,37 @@ command: locale-gen es_ES when: ansible_os_family == 'Debian' -- name: install i18ndata - zypper: name=glibc-i18ndata state=present - when: ansible_os_family == 'Suse' - -- name: Generate pt_BR locale (Red Hat) - 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) - command: localedef -f ISO-8859-1 -i es_ES es_ES - when: ansible_os_family == "RedHat" or ansible_os_family == "Suse" +# Suse: locales are installed by default (glibc-locale package). +# Fedora 23: locales are installed by default (glibc-common package) +# CentOS: all locales are installed by default (glibc-common package) but some +# RPM macros could prevent their installation (for example when using anaconda +# instLangs parameter). + +- block: + - name: Check if locales need to be generated (RedHat) + 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) lineinfile: diff --git a/test/integration/targets/setup_postgresql_db/vars/Debian-8.yml b/test/integration/targets/setup_postgresql_db/vars/Debian-8.yml index f829bd19967..c5c6795eac3 100644 --- a/test/integration/targets/setup_postgresql_db/vars/Debian-8.yml +++ b/test/integration/targets/setup_postgresql_db/vars/Debian-8.yml @@ -1,5 +1,3 @@ -postgresql_service: "postgresql" - postgresql_packages: - "postgresql" - "postgresql-common" diff --git a/test/integration/targets/setup_postgresql_db/vars/FreeBSD.yml b/test/integration/targets/setup_postgresql_db/vars/FreeBSD.yml index b61bef469e4..e297c6e4c68 100644 --- a/test/integration/targets/setup_postgresql_db/vars/FreeBSD.yml +++ b/test/integration/targets/setup_postgresql_db/vars/FreeBSD.yml @@ -1,5 +1,3 @@ -postgresql_service: "postgresql" - postgresql_packages: - "postgresql93-server" - "py27-psycopg2" diff --git a/test/integration/targets/setup_postgresql_db/vars/Ubuntu-12.yml b/test/integration/targets/setup_postgresql_db/vars/Ubuntu-12.yml index b29242914f6..4b6e744b441 100644 --- a/test/integration/targets/setup_postgresql_db/vars/Ubuntu-12.yml +++ b/test/integration/targets/setup_postgresql_db/vars/Ubuntu-12.yml @@ -1,5 +1,3 @@ -postgresql_service: "postgresql" - postgresql_packages: - "postgresql" - "postgresql-common" diff --git a/test/integration/targets/setup_postgresql_db/vars/Ubuntu-14.yml b/test/integration/targets/setup_postgresql_db/vars/Ubuntu-14.yml index 7d704264da7..ffcc8dd4962 100644 --- a/test/integration/targets/setup_postgresql_db/vars/Ubuntu-14.yml +++ b/test/integration/targets/setup_postgresql_db/vars/Ubuntu-14.yml @@ -1,5 +1,3 @@ -postgresql_service: "postgresql" - postgresql_packages: - "postgresql" - "postgresql-common" diff --git a/test/integration/targets/setup_postgresql_db/vars/Ubuntu-16-py3.yml b/test/integration/targets/setup_postgresql_db/vars/Ubuntu-16-py3.yml index 1c5fd353dc2..b088c3105ea 100644 --- a/test/integration/targets/setup_postgresql_db/vars/Ubuntu-16-py3.yml +++ b/test/integration/targets/setup_postgresql_db/vars/Ubuntu-16-py3.yml @@ -1,5 +1,3 @@ -postgresql_service: "postgresql" - postgresql_packages: - "postgresql" - "postgresql-common" diff --git a/test/integration/targets/setup_postgresql_db/vars/Ubuntu-16.yml b/test/integration/targets/setup_postgresql_db/vars/Ubuntu-16.yml index 7b6092a12c0..897efd2c769 100644 --- a/test/integration/targets/setup_postgresql_db/vars/Ubuntu-16.yml +++ b/test/integration/targets/setup_postgresql_db/vars/Ubuntu-16.yml @@ -1,5 +1,3 @@ -postgresql_service: "postgresql" - postgresql_packages: - "postgresql" - "postgresql-common" diff --git a/test/integration/targets/setup_postgresql_db/vars/default.yml b/test/integration/targets/setup_postgresql_db/vars/default.yml index dc7db0fc981..ab36dd9f1d2 100644 --- a/test/integration/targets/setup_postgresql_db/vars/default.yml +++ b/test/integration/targets/setup_postgresql_db/vars/default.yml @@ -1,5 +1,3 @@ -postgresql_service: "postgresql" - postgresql_packages: - "postgresql-server" - "python-psycopg2"