--- /dev/null
+---
+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/
- 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
- 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 }}"
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
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
-localhost
+localhost ansible_connection=local