diff options
author | Gaëtan Duchaussois <gaetan.duchaussois@fretlink.com> | 2018-04-20 14:40:33 +0200 |
---|---|---|
committer | Gaëtan Duchaussois <gaetan.duchaussois@fretlink.com> | 2018-04-20 14:40:33 +0200 |
commit | d213edd127a145821e419e80104a838da421e7ca (patch) | |
tree | 33c33a4560d7b3f55eaebaad6c107f5d01768f7c | |
parent | ad5e125af59a34020943158999564af4f3a41a59 (diff) | |
download | ansible-kong-app-d213edd127a145821e419e80104a838da421e7ca.tar.gz ansible-kong-app-d213edd127a145821e419e80104a838da421e7ca.tar.zst ansible-kong-app-d213edd127a145821e419e80104a838da421e7ca.zip |
add travis configuration and fix tests
-rw-r--r-- | .travis.yml | 32 | ||||
-rw-r--r-- | tasks/kong-app.yml | 6 | ||||
-rw-r--r-- | tasks/plugins.yml | 6 | ||||
-rw-r--r-- | tasks/routes.yml | 1 | ||||
-rw-r--r-- | tests/inventory | 2 |
5 files changed, 42 insertions, 5 deletions
diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..812d0fe --- /dev/null +++ b/.travis.yml | |||
@@ -0,0 +1,32 @@ | |||
1 | --- | ||
2 | language: python | ||
3 | python: "2.7" | ||
4 | |||
5 | # Use the new container infrastructure | ||
6 | sudo: false | ||
7 | |||
8 | # Install ansible | ||
9 | addons: | ||
10 | apt: | ||
11 | packages: | ||
12 | - python-pip | ||
13 | |||
14 | install: | ||
15 | # Install ansible | ||
16 | - pip install ansible | ||
17 | - pip install ansible-lint | ||
18 | |||
19 | # Check ansible version | ||
20 | - ansible --version | ||
21 | |||
22 | # Create ansible.cfg with correct roles_path | ||
23 | - printf '[defaults]\nroles_path=../' >ansible.cfg | ||
24 | |||
25 | script: | ||
26 | # Basic role syntax check | ||
27 | - ansible-playbook tests/test.yml -i tests/inventory --syntax-check | ||
28 | - ansible-lint . | ||
29 | - ansible-playbook tests/test.yml -i tests/inventory -C -D | ||
30 | |||
31 | notifications: | ||
32 | webhooks: https://galaxy.ansible.com/api/v1/notifications/ | ||
diff --git a/tasks/kong-app.yml b/tasks/kong-app.yml index e162c09..df95f2e 100644 --- a/tasks/kong-app.yml +++ b/tasks/kong-app.yml | |||
@@ -9,13 +9,15 @@ | |||
9 | 9 | ||
10 | - name: Update or Create service | 10 | - name: Update or Create service |
11 | uri: | 11 | uri: |
12 | url: "{{ kong_app_admin_url }}/services/{{ (kong_app_check_service.status == 404) | ternary('', kong_app_service_name) }}" | 12 | url: "{{ kong_app_admin_url }}/services/{{ exists_service | ternary('', kong_app_service_name) }}" |
13 | method: "{{ (kong_app_check_service.status == 404) | ternary('POST', 'PATCH') }}" | 13 | method: "{{ exists_service | ternary('POST', 'PATCH') }}" |
14 | body: "{{ kong_app_service_body | to_json }}" | 14 | body: "{{ kong_app_service_body | to_json }}" |
15 | status_code: 200,201 | 15 | status_code: 200,201 |
16 | headers: | 16 | headers: |
17 | apikey: "{{ kong_app_admin_apikey }}" | 17 | apikey: "{{ kong_app_admin_apikey }}" |
18 | Content-Type: application/json | 18 | Content-Type: application/json |
19 | vars: | ||
20 | exists_service: "{{ kong_app_check_service.status|default(404) == 404 }}" | ||
19 | 21 | ||
20 | - name: Setup plugins | 22 | - name: Setup plugins |
21 | import_tasks: plugins.yml | 23 | import_tasks: plugins.yml |
diff --git a/tasks/plugins.yml b/tasks/plugins.yml index 84f3d49..c03bca7 100644 --- a/tasks/plugins.yml +++ b/tasks/plugins.yml | |||
@@ -9,8 +9,8 @@ | |||
9 | 9 | ||
10 | - name: Setup plugin | 10 | - name: Setup plugin |
11 | uri: | 11 | uri: |
12 | url: "{{ kong_app_admin_url }}/{{ (current_config.id == '') | ternary('services/' ~ kong_app_service_name ~ '/plugins','plugins/' ~ current_config.id) }}" | 12 | url: "{{ kong_app_admin_url }}/{{ exists_plugin | ternary('services/' ~ kong_app_service_name ~ '/plugins','plugins/' ~ current_config.id) }}" |
13 | method: "{{ (current_config.id == '') | ternary ('POST', 'PATCH') }}" | 13 | method: "{{ exists_plugin | ternary ('POST', 'PATCH') }}" |
14 | body: "{{ plugin | combine(current_body) | to_json }}" | 14 | body: "{{ plugin | combine(current_body) | to_json }}" |
15 | headers: | 15 | headers: |
16 | apikey: "{{ kong_app_admin_apikey }}" | 16 | apikey: "{{ kong_app_admin_apikey }}" |
@@ -24,3 +24,5 @@ | |||
24 | current_id_hash: | 24 | current_id_hash: |
25 | id: "{{ current_config.id }}" | 25 | id: "{{ current_config.id }}" |
26 | current_body: "{{ (current_id_hash.id == '') | ternary({}, current_id_hash) }}" | 26 | current_body: "{{ (current_id_hash.id == '') | ternary({}, current_id_hash) }}" |
27 | exists_plugin: "{{ current_id_hash.id == '' }}" | ||
28 | when: not kong_app_service_plugins_check|skipped | ||
diff --git a/tasks/routes.yml b/tasks/routes.yml index bbcdb76..d4d912f 100644 --- a/tasks/routes.yml +++ b/tasks/routes.yml | |||
@@ -28,3 +28,4 @@ | |||
28 | apikey: "{{ kong_app_admin_apikey }}" | 28 | apikey: "{{ kong_app_admin_apikey }}" |
29 | status_code: 204 | 29 | status_code: 204 |
30 | with_items: "{{ kong_app_service_routes_check.json.data }}" | 30 | with_items: "{{ kong_app_service_routes_check.json.data }}" |
31 | when: not kong_app_service_routes_check|skipped | ||
diff --git a/tests/inventory b/tests/inventory index 878877b..49d4fe2 100644 --- a/tests/inventory +++ b/tests/inventory | |||
@@ -1,2 +1,2 @@ | |||
1 | localhost | 1 | localhost ansible_connection=local |
2 | 2 | ||