]> git.immae.eu Git - github/fretlink/ansible-kong-app.git/commitdiff
add travis configuration and fix tests
authorGaëtan Duchaussois <gaetan.duchaussois@fretlink.com>
Fri, 20 Apr 2018 12:40:33 +0000 (14:40 +0200)
committerGaëtan Duchaussois <gaetan.duchaussois@fretlink.com>
Fri, 20 Apr 2018 12:40:33 +0000 (14:40 +0200)
.travis.yml [new file with mode: 0644]
tasks/kong-app.yml
tasks/plugins.yml
tasks/routes.yml
tests/inventory

diff --git a/.travis.yml b/.travis.yml
new file mode 100644 (file)
index 0000000..812d0fe
--- /dev/null
@@ -0,0 +1,32 @@
+---
+language: python
+python: "2.7"
+
+# Use the new container infrastructure
+sudo: false
+
+# Install ansible
+addons:
+  apt:
+    packages:
+    - python-pip
+
+install:
+  # Install ansible
+  - pip install ansible
+  - pip install ansible-lint
+
+  # Check ansible version
+  - ansible --version
+
+  # Create ansible.cfg with correct roles_path
+  - printf '[defaults]\nroles_path=../' >ansible.cfg
+
+script:
+  # Basic role syntax check
+  - ansible-playbook tests/test.yml -i tests/inventory --syntax-check
+  - ansible-lint .
+  - ansible-playbook tests/test.yml -i tests/inventory -C -D
+
+notifications:
+  webhooks: https://galaxy.ansible.com/api/v1/notifications/
index e162c0924ab7315c389de94735aa4d26f2d50a6b..df95f2ec27a1633d84d042dafa12b36ce762345e 100644 (file)
@@ -9,13 +9,15 @@
 
 - name: Update or Create service
   uri:
-    url: "{{ kong_app_admin_url }}/services/{{ (kong_app_check_service.status == 404) | ternary('', kong_app_service_name) }}"
-    method: "{{ (kong_app_check_service.status == 404) | ternary('POST', 'PATCH') }}"
+    url: "{{ kong_app_admin_url }}/services/{{ exists_service | ternary('', kong_app_service_name) }}"
+    method: "{{ exists_service | ternary('POST', 'PATCH') }}"
     body: "{{ kong_app_service_body | to_json }}"
     status_code: 200,201
     headers:
       apikey: "{{ kong_app_admin_apikey }}"
       Content-Type: application/json
+  vars:
+    exists_service: "{{ kong_app_check_service.status|default(404) == 404 }}"
 
 - name: Setup plugins
   import_tasks: plugins.yml
index 84f3d49e7f60d77cf396156792c054d85887a145..c03bca740a4ae36789b9163f008a6f754e50d14d 100644 (file)
@@ -9,8 +9,8 @@
 
 - name: Setup plugin
   uri:
-    url: "{{ kong_app_admin_url }}/{{ (current_config.id == '') | ternary('services/' ~ kong_app_service_name ~ '/plugins','plugins/' ~ current_config.id) }}"
-    method: "{{ (current_config.id == '') | ternary ('POST', 'PATCH') }}"
+    url: "{{ kong_app_admin_url }}/{{ exists_plugin | ternary('services/' ~ kong_app_service_name ~ '/plugins','plugins/' ~ current_config.id) }}"
+    method: "{{ exists_plugin | ternary ('POST', 'PATCH') }}"
     body: "{{ plugin | combine(current_body)  | to_json }}"
     headers:
       apikey: "{{ kong_app_admin_apikey }}"
@@ -24,3 +24,5 @@
     current_id_hash:
       id: "{{ current_config.id }}"
     current_body: "{{ (current_id_hash.id == '') | ternary({}, current_id_hash) }}"
+    exists_plugin: "{{ current_id_hash.id == '' }}"
+  when: not kong_app_service_plugins_check|skipped
index bbcdb765568e6fec55e337b765d23f3dff3e2d8d..d4d912fdbd24b3ed1d1ac447f5066c934cba77ae 100644 (file)
@@ -28,3 +28,4 @@
       apikey: "{{ kong_app_admin_apikey }}"
     status_code: 204
   with_items: "{{ kong_app_service_routes_check.json.data }}"
+  when: not kong_app_service_routes_check|skipped
index 878877b0776c44f55fc4e458f70840f31da5bb01..49d4fe2b5512af203cb13f051d20bf17a7c911ac 100644 (file)
@@ -1,2 +1,2 @@
-localhost
+localhost ansible_connection=local