aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--.travis.yml9
-rw-r--r--test/main.yml28
-rw-r--r--test/requirements.yml2
3 files changed, 23 insertions, 16 deletions
diff --git a/.travis.yml b/.travis.yml
index c424411..ddf6fb0 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -11,6 +11,10 @@ addons:
11 packages: 11 packages:
12 - python-pip 12 - python-pip
13 13
14# Tests are using docker to spawn fake instances
15services:
16 - docker
17
14install: 18install:
15 # Install ansible 19 # Install ansible
16 - pip install ansible docker-py docker 20 - pip install ansible docker-py docker
@@ -22,7 +26,10 @@ script:
22 # Basic role syntax check 26 # Basic role syntax check
23 - ansible-playbook test/main.yml -i test/hosts --syntax-check 27 - ansible-playbook test/main.yml -i test/hosts --syntax-check
24 # Run the tests 28 # Run the tests
25 - ansible-playbook test/main.yml -i test/hosts 29 # FAILS - ansible-playbook test/main.yml -i test/hosts
30 # Even if Docker and docker-py module are present, the tests fail on Travis
31 # The error on Travis is:
32 # => {"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)"}
26 33
27notifications: 34notifications:
28 webhooks: https://galaxy.ansible.com/api/v1/notifications/ 35 webhooks: https://galaxy.ansible.com/api/v1/notifications/
diff --git a/test/main.yml b/test/main.yml
index bc9d27c..a4834be 100644
--- a/test/main.yml
+++ b/test/main.yml
@@ -117,18 +117,19 @@
117 - name: "{{ postgres_barman_directory }}" 117 - name: "{{ postgres_barman_directory }}"
118 description: 'Main database' 118 description: 'Main database'
119 primary_host: postgres_one 119 primary_host: postgres_one
120 primary_barman_password: "secret_cocktail" 120 postgres_barman_password: "secret_cocktail"
121 backup_method: rsync 121 backup_method: rsync
122 ansible_group: db-all 122 standby_hosts: "{{ groups['db-all'][1:] }}"
123 retention_policy: 'RECOVERY WINDOW OF 7 DAYS' 123 retention_policy: 'RECOVERY WINDOW OF 7 DAYS'
124 with_items: 124 with_items:
125 - postgres_barman 125 - postgres_barman
126 tags: provision_docker 126 tags: provision_docker
127 127
128- name: Test installing Barman role 128- name: Test installing Postgresql role
129 hosts: barman 129 hosts: primary:secondary
130 connection: docker 130 connection: docker
131 vars: {} 131 vars:
132 postgres_listen_addresses: "{{ hostvars[inventory_hostname].ansible_default_ipv4.address }}"
132 pre_tasks: &pre_tasks 133 pre_tasks: &pre_tasks
133 - name: "Build hosts file" 134 - name: "Build hosts file"
134 shell: 'echo "{{ hostvars[inventory_hostname].ansible_default_ipv4.address }} {{inventory_hostname}}" >> /etc/hosts' 135 shell: 'echo "{{ hostvars[inventory_hostname].ansible_default_ipv4.address }} {{inventory_hostname}}" >> /etc/hosts'
@@ -136,15 +137,6 @@
136 137
137 - debug: msg="Running on host {{inventory_hostname}} ({{ hostvars[inventory_hostname].ansible_default_ipv4.address }})" 138 - debug: msg="Running on host {{inventory_hostname}} ({{ hostvars[inventory_hostname].ansible_default_ipv4.address }})"
138 roles: 139 roles:
139 - { role: barman, tags: ['barman'] }
140
141- name: Test installing Postgresql role
142 hosts: primary:secondary
143 connection: docker
144 vars:
145 postgres_listen_addresses: "{{ hostvars[inventory_hostname].ansible_default_ipv4.address }}"
146 pre_tasks: *pre_tasks
147 roles:
148 - { role: ansible-postgresql-role, tags: ['postgres'] } 140 - { role: ansible-postgresql-role, tags: ['postgres'] }
149 tasks: 141 tasks:
150 - name: Start postgres cluster 142 - name: Start postgres cluster
@@ -157,6 +149,14 @@
157 command: psql --port=5432 --command='select NOW()' 149 command: psql --port=5432 --command='select NOW()'
158 150
159 151
152- name: Test installing Barman role
153 hosts: barman
154 connection: docker
155 vars: {}
156 pre_tasks: *pre_tasks
157 roles:
158 - { role: barman, tags: ['barman'] }
159
160- name: Test running Postgresql role when database is started 160- name: Test running Postgresql role when database is started
161 connection: docker 161 connection: docker
162 hosts: primary:secondary 162 hosts: primary:secondary
diff --git a/test/requirements.yml b/test/requirements.yml
index 4c72838..f9d7099 100644
--- a/test/requirements.yml
+++ b/test/requirements.yml
@@ -3,4 +3,4 @@
3 version: 7a6243dfcf69f9d262877eca487bc14b62ba6960 3 version: 7a6243dfcf69f9d262877eca487bc14b62ba6960
4- src: trainline-eu.ansible_barman_role 4- src: trainline-eu.ansible_barman_role
5 name: barman 5 name: barman
6 version: 1.0.0 6 version: 1.1.0