]> git.immae.eu Git - github/fretlink/ansible-postgresql-role.git/commitdiff
tests: running tests on all supported PG versions
authorPaul B <paul@bonaud.fr>
Wed, 6 May 2020 15:04:20 +0000 (17:04 +0200)
committerPaul B <paul@bonaud.fr>
Mon, 11 May 2020 13:11:43 +0000 (15:11 +0200)
.travis.yml
meta/main.yml
tasks/postgres-user.yml
test/main.yml
test/requirements.txt
test/requirements.yml

index ddf6fb04af87be073845a6b175f7a99119917418..c84bc8082a5375ee20ea46ff9e4d8fb13fd7a4e7 100644 (file)
@@ -1,9 +1,20 @@
 ---
+dist: bionic
 language: python
-python: "3.5"
+python: "3.8"
 
-# Use the new container infrastructure
-sudo: false
+# Test on all supported PG versions on both debian stretch and debian buster
+env:
+- POSTGRESQL_VERSION=9.5 DEBIAN_RELEASE=stretch
+- POSTGRESQL_VERSION=9.6 DEBIAN_RELEASE=stretch
+- POSTGRESQL_VERSION=10 DEBIAN_RELEASE=stretch
+- POSTGRESQL_VERSION=11 DEBIAN_RELEASE=stretch
+- POSTGRESQL_VERSION=12 DEBIAN_RELEASE=stretch
+- POSTGRESQL_VERSION=9.5 DEBIAN_RELEASE=buster
+- POSTGRESQL_VERSION=9.6 DEBIAN_RELEASE=buster
+- POSTGRESQL_VERSION=10 DEBIAN_RELEASE=buster
+- POSTGRESQL_VERSION=11 DEBIAN_RELEASE=buster
+- POSTGRESQL_VERSION=12 DEBIAN_RELEASE=buster
 
 # Install pip
 addons:
@@ -17,7 +28,7 @@ services:
 
 install:
   # Install ansible
-  - pip install ansible docker-py docker
+  - pip install -r test/requirements.txt
   # Check ansible version
   - ansible --version
   - ansible-galaxy install -r test/requirements.yml -p test/roles/
@@ -26,6 +37,7 @@ script:
   # Basic role syntax check
   - ansible-playbook test/main.yml -i test/hosts --syntax-check
   # Run the tests
+  - ansible-playbook test/main.yml -i test/hosts -e "postgres_version=${POSTGRESQL_VERSION}" -e "debian_release=${DEBIAN_RELEASE}"
   # FAILS - ansible-playbook test/main.yml -i test/hosts
   # Even if Docker and docker-py module are present, the tests fail on Travis
   # The error on Travis is:
index 2d7ff6152419d1bf62596062629474451ed33d67..659083e8e5e5aabc5ea7b6d9b1820e0264a467d9 100644 (file)
@@ -14,6 +14,7 @@ galaxy_info:
     versions:
       - jessie
       - stretch
+      - buster
 
   galaxy_tags: ['postgresql', 'cluster', 'ha', 'database', 'replication']
 
index fcef9fc42717017efd8d2ff7341964c68a10b3fd..000ea80c3f13f7e256bb379ce65b604d7d46f3bc 100644 (file)
@@ -8,6 +8,12 @@
   check_mode: no
   changed_when: false
 
+- name: "Install required packages for 'postgres_user' ansible module"
+  apt:
+    name:
+      - libpq-dev
+      - python-psycopg2
+
 - name: Create PostgreSQL user
   become: true
   become_user: postgres
index a4834be49be7be0699f8ada8a5dfefac60ba1242..6a819d833f309b1f6766610e875c693be4cb2153 100644 (file)
@@ -2,8 +2,7 @@
 - name: Bring up docker containers
   hosts: localhost
   vars: &common_vars
-    postgres_version: 11
-    postgres_barman_directory: 'test-postgres-11'
+    postgres_barman_directory: "test-postgres-{{ postgres_version }}"
     postgres_barman_server: postgres_barman
     barman_rsync_password: "secret_rsync"
     barman_rsync_allowed_hosts: 172.17.0.0/24
         range: 172.17.0.0/24
     inventory:
       - name: "{{ postgres_barman_server }}"
-        image: "python:3.7-stretch"
+        image: "python:3.7-{{ debian_release }}"
       - name: postgres_one
-        image: "python:3.7-stretch"
+        image: "python:3.7-{{ debian_release }}"
         links:
           - "{{ postgres_barman_server }}"
       - name: postgres_two
-        image: "python:3.7-stretch"
+        image: "python:3.7-{{ debian_release }}"
         links:
           - "{{ postgres_barman_server }}"
           - postgres_one
       - name: postgres_three
-        image: "python:3.7-stretch"
+        image: "python:3.7-{{ debian_release }}"
         links:
           - "{{ postgres_barman_server }}"
           - postgres_one
   roles:
     - role: provision_docker
-      provision_docker_inventory: "{{inventory}}"
-      provision_docker_use_docker_connection: true
+      vars:
+        provision_docker_inventory: "{{inventory}}"
+        provision_docker_use_docker_connection: true
+        ansible_connection: local
+        ansible_python_interpreter: "{{ansible_playbook_python}}"
   tasks:
     - name: Group primary
       add_host:
@@ -63,7 +65,7 @@
                 extensions:
                   - description: PostGis
                     apt_deps:
-                      - "postgresql-{{ postgres_version }}-postgis"
+                      - "postgresql-{{ postgres_version }}-postgis-3"
                     names:
                       - postgis
                       - postgis_topology
   hosts: primary:secondary
   connection: docker
   vars:
-    postgres_listen_addresses: "{{ hostvars[inventory_hostname].ansible_default_ipv4.address }}"
+    postgres_listen_addresses: ["{{ hostvars[inventory_hostname].ansible_default_ipv4.address }}"]
   pre_tasks: &pre_tasks
-     - name: "Build hosts file"
-       shell: 'echo "{{ hostvars[inventory_hostname].ansible_default_ipv4.address }} {{inventory_hostname}}" >> /etc/hosts'
-       when: hostvars[inventory_hostname].ansible_default_ipv4.address is defined
+    - name: "Build hosts file"
+      shell: 'echo "{{ hostvars[inventory_hostname].ansible_default_ipv4.address }} {{inventory_hostname}}" >> /etc/hosts'
+      when: hostvars[inventory_hostname].ansible_default_ipv4.address is defined
 
-     - debug: msg="Running on host {{inventory_hostname}} ({{ hostvars[inventory_hostname].ansible_default_ipv4.address }})"
+    - debug: msg="Running on host {{inventory_hostname}} ({{ hostvars[inventory_hostname].ansible_default_ipv4.address }})"
   roles:
     - { role: ansible-postgresql-role, tags: ['postgres'] }
   tasks:
   connection: docker
   hosts: primary:secondary
   vars:
-    postgres_listen_addresses: "{{ hostvars[inventory_hostname].ansible_default_ipv4.address }}"
+    postgres_listen_addresses: ["{{ hostvars[inventory_hostname].ansible_default_ipv4.address }}"]
   pre_tasks: *pre_tasks
   roles:
     - { role: ansible-postgresql-role, tags: ['postgres'] }
index d2cbb1abc1518be9c9d4d80d80e05745b2e5b6ed..3dfa5a6078558aa07cbcaaae5e77fbcc67f11c0b 100644 (file)
@@ -1 +1,2 @@
-docker-py
+ansible
+docker
index f9d7099d302e0a202bfd8555d8dbb4e614c88704..7c4133587fdc74f1ad608472c7d3c7bf6d4afce8 100644 (file)
@@ -1,6 +1,6 @@
 - src: chrismeyersfsu.provision_docker
   name: provision_docker
-  version: 7a6243dfcf69f9d262877eca487bc14b62ba6960
+  version: d68ce0aa486eff7669011ee2f9eaf68b95184ce1
 - src: trainline-eu.ansible_barman_role
   name: barman
   version: 1.1.0