aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorPaul B <paul@bonaud.fr>2020-05-06 17:04:20 +0200
committerPaul B <paul@bonaud.fr>2020-05-11 15:11:43 +0200
commit0415357ede1fc2f2e1ebd543a96551fcd8a046fe (patch)
treea35f68cfaf4e24740b6b1cf078689b4919a07f4f
parent8d1689150f638c6330e321eba7baf3f97678216a (diff)
downloadansible-postgresql-role-0415357ede1fc2f2e1ebd543a96551fcd8a046fe.tar.gz
ansible-postgresql-role-0415357ede1fc2f2e1ebd543a96551fcd8a046fe.tar.zst
ansible-postgresql-role-0415357ede1fc2f2e1ebd543a96551fcd8a046fe.zip
tests: running tests on all supported PG versions
-rw-r--r--.travis.yml20
-rw-r--r--meta/main.yml1
-rw-r--r--tasks/postgres-user.yml6
-rw-r--r--test/main.yml32
-rw-r--r--test/requirements.txt3
-rw-r--r--test/requirements.yml2
6 files changed, 43 insertions, 21 deletions
diff --git a/.travis.yml b/.travis.yml
index ddf6fb0..c84bc80 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,9 +1,20 @@
1--- 1---
2dist: bionic
2language: python 3language: python
3python: "3.5" 4python: "3.8"
4 5
5# Use the new container infrastructure 6# Test on all supported PG versions on both debian stretch and debian buster
6sudo: false 7env:
8- POSTGRESQL_VERSION=9.5 DEBIAN_RELEASE=stretch
9- POSTGRESQL_VERSION=9.6 DEBIAN_RELEASE=stretch
10- POSTGRESQL_VERSION=10 DEBIAN_RELEASE=stretch
11- POSTGRESQL_VERSION=11 DEBIAN_RELEASE=stretch
12- POSTGRESQL_VERSION=12 DEBIAN_RELEASE=stretch
13- POSTGRESQL_VERSION=9.5 DEBIAN_RELEASE=buster
14- POSTGRESQL_VERSION=9.6 DEBIAN_RELEASE=buster
15- POSTGRESQL_VERSION=10 DEBIAN_RELEASE=buster
16- POSTGRESQL_VERSION=11 DEBIAN_RELEASE=buster
17- POSTGRESQL_VERSION=12 DEBIAN_RELEASE=buster
7 18
8# Install pip 19# Install pip
9addons: 20addons:
@@ -17,7 +28,7 @@ services:
17 28
18install: 29install:
19 # Install ansible 30 # Install ansible
20 - pip install ansible docker-py docker 31 - pip install -r test/requirements.txt
21 # Check ansible version 32 # Check ansible version
22 - ansible --version 33 - ansible --version
23 - ansible-galaxy install -r test/requirements.yml -p test/roles/ 34 - ansible-galaxy install -r test/requirements.yml -p test/roles/
@@ -26,6 +37,7 @@ script:
26 # Basic role syntax check 37 # Basic role syntax check
27 - ansible-playbook test/main.yml -i test/hosts --syntax-check 38 - ansible-playbook test/main.yml -i test/hosts --syntax-check
28 # Run the tests 39 # Run the tests
40 - ansible-playbook test/main.yml -i test/hosts -e "postgres_version=${POSTGRESQL_VERSION}" -e "debian_release=${DEBIAN_RELEASE}"
29 # FAILS - ansible-playbook test/main.yml -i test/hosts 41 # FAILS - ansible-playbook test/main.yml -i test/hosts
30 # Even if Docker and docker-py module are present, the tests fail on Travis 42 # Even if Docker and docker-py module are present, the tests fail on Travis
31 # The error on Travis is: 43 # The error on Travis is:
diff --git a/meta/main.yml b/meta/main.yml
index 2d7ff61..659083e 100644
--- a/meta/main.yml
+++ b/meta/main.yml
@@ -14,6 +14,7 @@ galaxy_info:
14 versions: 14 versions:
15 - jessie 15 - jessie
16 - stretch 16 - stretch
17 - buster
17 18
18 galaxy_tags: ['postgresql', 'cluster', 'ha', 'database', 'replication'] 19 galaxy_tags: ['postgresql', 'cluster', 'ha', 'database', 'replication']
19 20
diff --git a/tasks/postgres-user.yml b/tasks/postgres-user.yml
index fcef9fc..000ea80 100644
--- a/tasks/postgres-user.yml
+++ b/tasks/postgres-user.yml
@@ -8,6 +8,12 @@
8 check_mode: no 8 check_mode: no
9 changed_when: false 9 changed_when: false
10 10
11- name: "Install required packages for 'postgres_user' ansible module"
12 apt:
13 name:
14 - libpq-dev
15 - python-psycopg2
16
11- name: Create PostgreSQL user 17- name: Create PostgreSQL user
12 become: true 18 become: true
13 become_user: postgres 19 become_user: postgres
diff --git a/test/main.yml b/test/main.yml
index a4834be..6a819d8 100644
--- a/test/main.yml
+++ b/test/main.yml
@@ -2,8 +2,7 @@
2- name: Bring up docker containers 2- name: Bring up docker containers
3 hosts: localhost 3 hosts: localhost
4 vars: &common_vars 4 vars: &common_vars
5 postgres_version: 11 5 postgres_barman_directory: "test-postgres-{{ postgres_version }}"
6 postgres_barman_directory: 'test-postgres-11'
7 postgres_barman_server: postgres_barman 6 postgres_barman_server: postgres_barman
8 barman_rsync_password: "secret_rsync" 7 barman_rsync_password: "secret_rsync"
9 barman_rsync_allowed_hosts: 172.17.0.0/24 8 barman_rsync_allowed_hosts: 172.17.0.0/24
@@ -15,25 +14,28 @@
15 range: 172.17.0.0/24 14 range: 172.17.0.0/24
16 inventory: 15 inventory:
17 - name: "{{ postgres_barman_server }}" 16 - name: "{{ postgres_barman_server }}"
18 image: "python:3.7-stretch" 17 image: "python:3.7-{{ debian_release }}"
19 - name: postgres_one 18 - name: postgres_one
20 image: "python:3.7-stretch" 19 image: "python:3.7-{{ debian_release }}"
21 links: 20 links:
22 - "{{ postgres_barman_server }}" 21 - "{{ postgres_barman_server }}"
23 - name: postgres_two 22 - name: postgres_two
24 image: "python:3.7-stretch" 23 image: "python:3.7-{{ debian_release }}"
25 links: 24 links:
26 - "{{ postgres_barman_server }}" 25 - "{{ postgres_barman_server }}"
27 - postgres_one 26 - postgres_one
28 - name: postgres_three 27 - name: postgres_three
29 image: "python:3.7-stretch" 28 image: "python:3.7-{{ debian_release }}"
30 links: 29 links:
31 - "{{ postgres_barman_server }}" 30 - "{{ postgres_barman_server }}"
32 - postgres_one 31 - postgres_one
33 roles: 32 roles:
34 - role: provision_docker 33 - role: provision_docker
35 provision_docker_inventory: "{{inventory}}" 34 vars:
36 provision_docker_use_docker_connection: true 35 provision_docker_inventory: "{{inventory}}"
36 provision_docker_use_docker_connection: true
37 ansible_connection: local
38 ansible_python_interpreter: "{{ansible_playbook_python}}"
37 tasks: 39 tasks:
38 - name: Group primary 40 - name: Group primary
39 add_host: 41 add_host:
@@ -63,7 +65,7 @@
63 extensions: 65 extensions:
64 - description: PostGis 66 - description: PostGis
65 apt_deps: 67 apt_deps:
66 - "postgresql-{{ postgres_version }}-postgis" 68 - "postgresql-{{ postgres_version }}-postgis-3"
67 names: 69 names:
68 - postgis 70 - postgis
69 - postgis_topology 71 - postgis_topology
@@ -129,13 +131,13 @@
129 hosts: primary:secondary 131 hosts: primary:secondary
130 connection: docker 132 connection: docker
131 vars: 133 vars:
132 postgres_listen_addresses: "{{ hostvars[inventory_hostname].ansible_default_ipv4.address }}" 134 postgres_listen_addresses: ["{{ hostvars[inventory_hostname].ansible_default_ipv4.address }}"]
133 pre_tasks: &pre_tasks 135 pre_tasks: &pre_tasks
134 - name: "Build hosts file" 136 - name: "Build hosts file"
135 shell: 'echo "{{ hostvars[inventory_hostname].ansible_default_ipv4.address }} {{inventory_hostname}}" >> /etc/hosts' 137 shell: 'echo "{{ hostvars[inventory_hostname].ansible_default_ipv4.address }} {{inventory_hostname}}" >> /etc/hosts'
136 when: hostvars[inventory_hostname].ansible_default_ipv4.address is defined 138 when: hostvars[inventory_hostname].ansible_default_ipv4.address is defined
137 139
138 - debug: msg="Running on host {{inventory_hostname}} ({{ hostvars[inventory_hostname].ansible_default_ipv4.address }})" 140 - debug: msg="Running on host {{inventory_hostname}} ({{ hostvars[inventory_hostname].ansible_default_ipv4.address }})"
139 roles: 141 roles:
140 - { role: ansible-postgresql-role, tags: ['postgres'] } 142 - { role: ansible-postgresql-role, tags: ['postgres'] }
141 tasks: 143 tasks:
@@ -161,7 +163,7 @@
161 connection: docker 163 connection: docker
162 hosts: primary:secondary 164 hosts: primary:secondary
163 vars: 165 vars:
164 postgres_listen_addresses: "{{ hostvars[inventory_hostname].ansible_default_ipv4.address }}" 166 postgres_listen_addresses: ["{{ hostvars[inventory_hostname].ansible_default_ipv4.address }}"]
165 pre_tasks: *pre_tasks 167 pre_tasks: *pre_tasks
166 roles: 168 roles:
167 - { role: ansible-postgresql-role, tags: ['postgres'] } 169 - { role: ansible-postgresql-role, tags: ['postgres'] }
diff --git a/test/requirements.txt b/test/requirements.txt
index d2cbb1a..3dfa5a6 100644
--- a/test/requirements.txt
+++ b/test/requirements.txt
@@ -1 +1,2 @@
1docker-py 1ansible
2docker
diff --git a/test/requirements.yml b/test/requirements.yml
index f9d7099..7c41335 100644
--- a/test/requirements.yml
+++ b/test/requirements.yml
@@ -1,6 +1,6 @@
1- src: chrismeyersfsu.provision_docker 1- src: chrismeyersfsu.provision_docker
2 name: provision_docker 2 name: provision_docker
3 version: 7a6243dfcf69f9d262877eca487bc14b62ba6960 3 version: d68ce0aa486eff7669011ee2f9eaf68b95184ce1
4- src: trainline-eu.ansible_barman_role 4- src: trainline-eu.ansible_barman_role
5 name: barman 5 name: barman
6 version: 1.1.0 6 version: 1.1.0