aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--LICENSE7
-rw-r--r--README.md50
-rwxr-xr-xtests/kong.py2
-rw-r--r--tests/test.yml3
4 files changed, 41 insertions, 21 deletions
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..9be8747
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,7 @@
1Copyright (c) 2020 Fretlink S.A.S
2
3Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4
5The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6
7THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \ No newline at end of file
diff --git a/README.md b/README.md
index 8db9391..e02203f 100644
--- a/README.md
+++ b/README.md
@@ -1,32 +1,34 @@
1kong-app 1kong-app
2========= 2=========
3 3
4This role aims at creating on a remote kong the service, routes and plugins needed by an app 4This role aims at creating, on a remote kong, a list of services, routes and plugins needed by an app. The API calls are made from the ansible target host. If you use `hosts: localhost` as a target from within your playbook then all API calls will be done from your local machine.
5 5
6Requirements 6Requirements
7------------ 7------------
8 8
9None at the moment 9A Kong server which you want to configure.
10
11If you want to configure this role with [Dhall](https://dhall-lang.org/) instead of YAML, the role publishes dhall bindings defined in the `dhall/package.dhall` file. These bindings will need Dhall version `1.29.0` or higher.
10 12
11Role Variables 13Role Variables
12-------------- 14--------------
13* `kong_servers`: an array of kong\_server to configure with followin configuration: 15* `kong_servers`: an array of kong_server to configure with the following configuration:
14 * `kong_app_admin_url` the kong admin url (mandatory). 16 * `kong_app_admin_url` the kong admin API url (mandatory).
15 * `kong_app_admin_apikey` the apikey to use kong admin api. Default to "" 17 * `kong_app_admin_apikey` the apikey to use during kong admin api calls. Defaults to `""`
16 * `services` an array of services to setup (default to []) 18 * `services` an array of services to setup. Defaults to `[]`.
17 * `name` the name of the service to create for this app, mandatory 19 * `name` the name of the service to create for this app, **mandatory**
18 * `url` the url of the backend of the app, mandatory. May refer to an upstream by its name (https://upstream\_name/path) 20 * `url` the url of the backend of the app, **mandatory**. May refer to an upstream by its name (https://upstream_name/path)
19 * `upstream` if the url reference an upstream a dict with the configuration, optional 21 * `upstream` if the url reference an upstream a dict with the configuration, optional
20 * `conf` the configuration as expected by kong for an upstream creation 22 * `conf` the configuration as expected by kong for an upstream creation
21 * `name` mandatory name for the upstream 23 * `name` mandatory name for the upstream
22 * `healthchecks` optional healthchecks configuration as expected by kong api 24 * `healthchecks` optional healthchecks configuration as expected by kong api
23 * `targets` an array of dict defining a target for kong 25 * `targets` an array of dict defining a target for kong
24 * `target` the host:port to reach the target (mandatory) 26 * `target` the host:port to reach the target, **mandatory** if a target is defined
25 * `weight` the weight of the target (optional) 27 * `weight` the weight of the target, optional
26 * `plugins` An array of plugins to activate with their name and config in a dict 28 * `plugins` An array of plugins to activate with their name and config in a dict. (Plugin objects are defined in the [Kong API documentation](https://docs.konghq.com/2.1.x/admin-api/#plugin-object))
27 * `name` 29 * `name`
28 * `config` 30 * `config`
29 * `routes` An array of routes to create for this service. 31 * `routes` An array of routes to create for this service. (Route objects are defined in the [Kong API documentation](https://docs.konghq.com/2.1.x/admin-api/#route-object))
30 * `hosts` 32 * `hosts`
31 * `paths` 33 * `paths`
32 * `protocols` 34 * `protocols`
@@ -35,26 +37,34 @@ Role Variables
35Dependencies 37Dependencies
36------------ 38------------
37 39
38 40None
39 41
40Example Playbook 42Example Playbook
41---------------- 43----------------
42 44
43 - hosts: localhost 45 - hosts: localhost
44 roles: 46 roles:
45 - { role: kong-app, kong_servers: [ kong_app_admin_url: http://localhost:8001, 47 - { role: kong-app,
46 services: [ name:example, 48 kong_servers:
47 url: http://example.com, 49 - kong_app_admin_url: http://localhost:8001,
48 plugins: [], 50 services:
49 routes: [ { hosts: [my.kong.example], paths: [/] } ]]] 51 - name: example,
52 url: http://example.com,
53 plugins: [],
54 routes: [ { hosts: [my.kong.example], paths: [/] } ]
50 } 55 }
51 56
57Tests
58----
59
60The role is tested with automated continuous integration tests on Travis (see `tests/` directory). The test playbook targets a fake Kong server (visible in `tests/kong.py`).
61
52License 62License
53------- 63-------
54 64
55TBD 65MIT (see LICENSE file for details)
56 66
57Author Information 67Author Information
58------------------ 68------------------
59 69
60FretLink Team 70Developed at [Fretlink](https://tech.fretlink.com)
diff --git a/tests/kong.py b/tests/kong.py
index 4e2df28..a1f9cec 100755
--- a/tests/kong.py
+++ b/tests/kong.py
@@ -13,7 +13,7 @@ class SimpleHTTPRequestHandler(CGIHTTPRequestHandler):
13 self.wfile.write(b'{ "data": [] }') 13 self.wfile.write(b'{ "data": [] }')
14 14
15 def do_POST(self): 15 def do_POST(self):
16 self.send_response(200) 16 self.send_response(201)
17 self.end_headers() 17 self.end_headers()
18 self.wfile.write(b'Hello, world!') 18 self.wfile.write(b'Hello, world!')
19 19
diff --git a/tests/test.yml b/tests/test.yml
index 36c81a2..cbe858f 100644
--- a/tests/test.yml
+++ b/tests/test.yml
@@ -10,3 +10,6 @@
10 services: 10 services:
11 - url: http://example.com 11 - url: http://example.com
12 name: test 12 name: test
13 routes:
14 - hosts: [my.kong.example]
15 paths: [/]