packages:
- python-pip
+# Tests are using docker to spawn fake instances
+services:
+ - docker
+
install:
# Install ansible
- pip install ansible docker-py docker
# 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
+ # 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:
+ # => {"changed": false, "item": {"image": "python:3.7-stretch", "links": ["postgres_barman", "postgres_one"], "name": "postgres_three"}, "msg": "Failed to import docker or docker-py - No module named docker. Try `pip install docker` or `pip install docker-py` (Python 2.6)"}
notifications:
webhooks: https://galaxy.ansible.com/api/v1/notifications/
- name: "{{ postgres_barman_directory }}"
description: 'Main database'
primary_host: postgres_one
- primary_barman_password: "secret_cocktail"
+ postgres_barman_password: "secret_cocktail"
backup_method: rsync
- ansible_group: db-all
+ standby_hosts: "{{ groups['db-all'][1:] }}"
retention_policy: 'RECOVERY WINDOW OF 7 DAYS'
with_items:
- postgres_barman
tags: provision_docker
-- name: Test installing Barman role
- hosts: barman
+- name: Test installing Postgresql role
+ hosts: primary:secondary
connection: docker
- vars: {}
+ vars:
+ 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
- debug: msg="Running on host {{inventory_hostname}} ({{ hostvars[inventory_hostname].ansible_default_ipv4.address }})"
- roles:
- - { role: barman, tags: ['barman'] }
-
-- name: Test installing Postgresql role
- hosts: primary:secondary
- connection: docker
- vars:
- postgres_listen_addresses: "{{ hostvars[inventory_hostname].ansible_default_ipv4.address }}"
- pre_tasks: *pre_tasks
roles:
- { role: ansible-postgresql-role, tags: ['postgres'] }
tasks:
command: psql --port=5432 --command='select NOW()'
+- name: Test installing Barman role
+ hosts: barman
+ connection: docker
+ vars: {}
+ pre_tasks: *pre_tasks
+ roles:
+ - { role: barman, tags: ['barman'] }
+
- name: Test running Postgresql role when database is started
connection: docker
hosts: primary:secondary