Fix broken tests, add Debian 8 test.

This commit is contained in:
Jeff Geerling 2016-09-29 14:33:39 -05:00
parent 9ef6bede6b
commit e742492e45
10 changed files with 61 additions and 4 deletions

View File

@ -5,15 +5,23 @@ env:
- distro: centos7
init: /usr/lib/systemd/systemd
run_opts: "--privileged --volume=/sys/fs/cgroup:/sys/fs/cgroup:ro"
postgres_bin_path: /usr/bin
- distro: centos6
init: /sbin/init
run_opts: ""
postgres_bin_path: /usr/bin
- distro: ubuntu1604
init: /lib/systemd/systemd
run_opts: "--privileged --volume=/sys/fs/cgroup:/sys/fs/cgroup:ro"
postgres_bin_path: /usr/lib/postgresql/9.5/bin
- distro: ubuntu1404
init: /sbin/init
run_opts: ""
postgres_bin_path: /usr/lib/postgresql/9.3/bin
- distro: debian8
init: /lib/systemd/systemd
run_opts: "--privileged --volume=/sys/fs/cgroup:/sys/fs/cgroup:ro"
postgres_bin_path: /usr/lib/postgresql/9.4/bin
services:
- docker
@ -43,7 +51,7 @@ script:
|| (echo 'Idempotence test: fail' && exit 1)
# Check PostgreSQL status.
- 'docker exec -u postgres "$(cat ${container_id})" pg_ctl -D /var/lib/pgsql/data status'
- 'docker exec -u postgres "$(cat ${container_id})" ${postgres_bin_path}/pg_ctl -D /var/lib/pgsql/data status'
after_failure:
# Check what happened on systemd systems.

View File

@ -49,6 +49,13 @@ TODO.
role_attr_flags: CREATEDB,NOSUPERUSER # optional
state: present # optional
TODO.
postgresql_version: [OS-specific]
postgresql_bin_path: [OS-specific]
postgresql_daemon: [OS-specific]
postgresql_packages: [OS-specific]
TODO.
## Dependencies

View File

@ -1,5 +1,5 @@
---
- name: Set PGDATA environment variable.
- name: Set PostgreSQL environment variables.
template:
src: postgres.sh.j2
dest: /etc/profile.d/postgres.sh
@ -19,7 +19,7 @@
register: pgdata_dir_version
- name: Ensure PostgreSQL database is initialized.
command: "initdb -D {{ postgresql_data_dir }}"
command: "{{ postgresql_bin_path }}/initdb -D {{ postgresql_data_dir }}"
when: not pgdata_dir_version.stat.exists
become: yes
become_user: "{{ postgresql_user }}"

View File

@ -1,7 +1,12 @@
---
# Variable configuration.
- name: Include OS-specific variables.
- name: Include OS-specific variables (Debian).
include_vars: "{{ ansible_distribution }}-{{ ansible_distribution_version }}.yml"
when: ansible_os_family == 'Debian'
- name: Include OS-specific variables (RedHat).
include_vars: "{{ ansible_os_family }}.yml"
when: ansible_os_family == 'RedHat'
- name: Define postgresql_packages.
set_fact:
@ -12,3 +17,13 @@
set_fact:
postgresql_daemon: "{{ __postgresql_daemon }}"
when: postgresql_daemon is not defined
- name: Define postgresql_version.
set_fact:
postgresql_version: "{{ __postgresql_version }}"
when: postgresql_version is not defined
- name: Define postgresql_bin_path.
set_fact:
postgresql_bin_path: "{{ __postgresql_bin_path }}"
when: postgresql_bin_path is not defined

View File

@ -1 +1,2 @@
export PGDATA={{ postgresql_data_dir }}
export PATH=$PATH:{{ postgresql_bin_path }}

View File

@ -1,6 +1,12 @@
---
- hosts: all
vars:
postgresql_databases:
- name: example
postgresql_users:
- name: jdoe
pre_tasks:
- name: Update apt cache.
apt: update_cache=yes

View File

@ -1,4 +1,6 @@
---
__postgresql_version: "9.5"
__postgresql_bin_path: "/usr/lib/postgresql/{{ __postgresql_version }}/bin"
__postgresql_daemon: postgresql
__postgresql_packages:
- postgresql

View File

@ -1,4 +1,6 @@
---
__postgresql_version: "9.2"
__postgresql_bin_path: "/usr/bin"
__postgresql_daemon: postgresql
__postgresql_packages:
- postgresql

8
vars/Ubuntu-1404.yml Normal file
View File

@ -0,0 +1,8 @@
---
__postgresql_version: "9.5"
__postgresql_bin_path: "/usr/lib/postgresql/{{ __postgresql_version }}/bin"
__postgresql_daemon: postgresql
__postgresql_packages:
- postgresql
- postgresql-contrib
- libpq-dev

8
vars/Ubuntu-1604.yml Normal file
View File

@ -0,0 +1,8 @@
---
__postgresql_version: "9.5"
__postgresql_bin_path: "/usr/lib/postgresql/{{ __postgresql_version }}/bin"
__postgresql_daemon: postgresql
__postgresql_packages:
- postgresql
- postgresql-contrib
- libpq-dev