wunzeco / ansible-kong Goto Github PK
View Code? Open in Web Editor NEWInstalls and Configures Kong
Installs and Configures Kong
The systemd file created to start the kong service doesn't have a listed dependency to wait for backend services (postgres, cassandra, etc) to start. If kong starts before these services, it will fail.
Does this role support installation of Kong v12 as well?
Thanks!
In the event that there are more than 100 consumers, kong paginates the consumer list, this can lead the consumer add task to incorrectly count a consumer as not existing as the consumer may not be on the first page. This causes the task to try to create a consumer and fails.
# Get list of consumer objects
- name: Get list of kong consumer objects
uri:
url: "{{ kong_admin_api_url }}/consumers"
register: consumers
Ansible 2.2.3
wunzeco/ansible-kong 1.10
When this block executes:
- name: register logging plugin for logstash
include_role:
name: wunzeco.kong
kong_task: plugin
kong_plugin_config:
name: tcp-log
service: prod-k8s
config: { host: "logstash-aggregator-elb.prod.airmap.com", port: "8888", timeout: "10000", keepalive: "60000" }
vars:
kong_use_old_config_format: false
kong_admin_api_url: "http://{{ hostvars[inventory_hostname]['ansible_default_ipv4']['address'] }}:8001"
run_once: true
for some unexplainable reason kong_task
has no value and therefore gets populated with the default, server
, and then installation of kong is attempted (which is not what i want at all.
I have other task blocks which register services and routes and they work fine. the plugin kong_task
seems to just get ignored.
Is there something weird about include_role
and Ansible 2.2.3 or am I missing something obvious about the task block?
Missing a closing }
{% if plugin_obj.update({'consumer': {'id': consumer.json.id}}) %}{% endif %}
Originally posted by @TaylorN15 in #25
Error on ansible-kong/tasks/plugin_add.yml:7
"matched_plugin_id": "", Can't update plugin when already exists.
- name: 0.0.1-initial.yml | Provision KONG
hosts: localhost
connection: local
become: yes
vars:
kong_version: 0.13.1
kong_use_old_config_format: false
roles:
#****************#
# SERVICES #
#****************#
# --------------- Profile User Statistics --------------- #
- role: ansible-kong
kong_task: service
kong_service_config:
service:
name: profile-users-stats
url: 'http://api.namspace.svc.cluster.local/api/v1/stats'
routes:
- paths: [ '/api/v1/stats', '/stats' ]
methods: [ 'GET', 'OPTIONS' ]
preserve_host: true
strip_path: true
- role: ansible-kong
kong_task: plugin
kong_plugin_config:
name: cors
service: profile-users-stats
config:
origins: '*'
methods: 'GET'
credentials: false
preflight_continue: false
If we run the playbook for the first time, services, routes and plugins will be created but the second execution it raises HTTP Error 409: Conflict when adding the plugin.
TASK [ansible-kong : Get matched plugin id] ****************************************************************************************************************************************************************
task path: /root/fugoki-ansible/roles/external/ansible-kong/tasks/plugin.yml:54
ok: [localhost] => {
"ansible_facts": {
"matched_plugin_id": ""
},
"changed": false,
"failed": false
}
TASK [ansible-kong : debug] ********************************************************************************************************************************************************************************
task path: /root/fugoki-ansible/roles/external/ansible-kong/tasks/plugin.yml:58
ok: [localhost] => {
"msg": "Plugin - cors"
}
TASK [ansible-kong : set_fact] *****************************************************************************************************************************************************************************
task path: /root/fugoki-ansible/roles/external/ansible-kong/tasks/plugin.yml:60
ok: [localhost] => {
"ansible_facts": {
"_cmd": "add"
},
"changed": false,
"failed": false
}
TASK [ansible-kong : set_fact] *****************************************************************************************************************************************************************************
task path: /root/fugoki-ansible/roles/external/ansible-kong/tasks/plugin.yml:62
skipping: [localhost] => {
"changed": false,
"skip_reason": "Conditional result was False",
"skipped": true
}
TASK [ansible-kong : Kong Plugin Object Config] ************************************************************************************************************************************************************
task path: /root/fugoki-ansible/roles/external/ansible-kong/tasks/plugin.yml:65
included: /root/fugoki-ansible/roles/external/ansible-kong/tasks/plugin_add.yml for localhost
TASK [ansible-kong : Initialise plugin_exists variable] ****************************************************************************************************************************************************
task path: /root/fugoki-ansible/roles/external/ansible-kong/tasks/plugin_add.yml:3
ok: [localhost] => {
"ansible_facts": {
"plugin_exists": false
},
"changed": false,
"failed": false
}
The full traceback is:
File "/tmp/ansible_MeVxIb/ansible_module_uri.py", line 468, in main
uresp['location'] = absolute_location(url, uresp['location'])
fatal: [localhost]: FAILED! => {
"access_control_allow_origin": "*",
"changed": false,
"connection": "close",
"content": "{\"name\":\"already exists with value 'cors'\"}\n",
"content_type": "application/json; charset=utf-8",
"date": "Fri, 25 May 2018 16:37:49 GMT",
"failed": true,
"invocation": {
"module_args": {
"attributes": null,
"backup": null,
"body": {
"config": {
"credentials": false,
"methods": "GET",
"origins": "*",
"preflight_continue": false
},
"name": "cors",
"service_id": "24654971-dbe8-4749-89f0-d7270c18d294"
},
"body_format": "json",
"client_cert": null,
"client_key": null,
"content": null,
"creates": null,
"delimiter": null,
"dest": null,
"directory_mode": null,
"follow": false,
"follow_redirects": "safe",
"force": false,
"force_basic_auth": false,
"group": null,
"headers": {
"Content-Type": "application/json"
},
"http_agent": "ansible-httpget",
"method": "POST",
"mode": null,
"owner": null,
"regexp": null,
"remote_src": null,
"removes": null,
"return_content": false,
"selevel": null,
"serole": null,
"setype": null,
"seuser": null,
"src": null,
"status_code": [
"201"
],
"timeout": 30,
"unsafe_writes": null,
"url": "http://kong:8001/plugins/",
"url_password": null,
"url_username": null,
"use_proxy": true,
"validate_certs": true
}
},
"json": {
"name": "already exists with value 'cors'"
},
"msg": "Status code was not [201]: HTTP Error 409: Conflict",
"redirected": false,
"server": "kong/0.13.1",
"status": 409,
"url": "http://kong:8001/plugins/",
"via": "1.1 packer-5a802b6f-987a-8190-ee48-0de9ff88de6b (squid/3.5.12)",
"x_cache": "MISS from packer-5a802b6f-987a-8190-ee48-0de9ff88de6b",
"x_cache_lookup": "MISS from packer-5a802b6f-987a-8190-ee48-0de9ff88de6b:3128"
}
I'm trying to create a global ip-restriction plugin, but the matched_plugin_id seems to be returning a list of all the plugins with the same type, therefore, the request to update fails.
Playbook
- hosts: dev
vars:
kong_version: 0.14.0
kong_use_old_config_format: false
roles:
- role: wunzeco.kong
kong_task: plugin
kong_plugin_config:
name: ip-restriction
config:
whitelist: [ "127.0.0.1" ]
Playbook run log (excerpt)
TASK [wunzeco.kong : Get matched plugin id] ****************************************************************************************************************************************
task path: /.ansible/roles/wunzeco.kong/tasks/plugin.yml:73
ok: [dev] => {
"ansible_facts": {
"matched_plugin_id": "ab7363ff-99a5-4043-a664-f6b31cb56f1a\n14c27ebc-1938-4ebf-8073-b20d366eb108\nc617d16d-8f4d-4dd4-b874-244b0167e957\nfc1b9141-162a-487e-8347-84c2e17dca8a\n308cd52c-cc4c-4851-909f-fc4d8c99c4ff\n7e99a7e1-a8e9-43b0-98e3-939a3c2c665f\nb4bee7a6-1c94-4e7f-b1a8-df1cb1a23c97\n10e543b8-4c37-48d4-864c-c7e1a665c864\n4f37bee7-105f-4439-8a4d-eb96594718e9\n983f0639-7109-4194-a370-7142c499b2ca\n58b97515-0bec-4feb-9cb7-e9f2bfc04f79\n38edc682-945c-41a9-ad5f-63dfea4a06e7\nf8f53ba3-701d-43e7-8461-41e4c96d557b\n4d1c4b46-499b-465d-a702-b01bc4314d2c\n84b64990-19d8-40f3-b4cb-3585dffc57e2\n6acb5294-db8e-463a-934e-1ac2ebc88ccc\na9be5c08-5511-4718-9d5d-824c691cbfc1\nc681069e-942c-42c5-94be-fdb02a211f51\nd0f37803-81e9-4ce1-a54d-b6a4a7c007d0\nad08250d-ec80-4af9-976a-5627017b8e0f\n8dbf537f-6558-45ba-8fbe-5f5beabecba8\n2c992df4-5a1c-4caf-be16-b6e4537bbe56\nafcbfd6d-bd5f-4bc9-b345-89d207caf3ef\n9ea42ec0-ea1c-49cf-bf65-c5eaa2580313\nd4253823-d492-46b7-8890-ae45ac250c76\n1531c69b-a031-4487-a2e4-ae02e8e7f2db\n89361b40-d111-4aa5-81e3-b43d6c5fca00"
},
"changed": false
}
Failed API call
fatal: [dev]: FAILED! => {
"changed": false,
"content": "",
"invocation": {
"module_args": {
"attributes": null,
"backup": null,
"body": {
"config": {
"whitelist": [
"127.0.0.1"
]
},
"name": "ip-restriction"
},
"body_format": "json",
"client_cert": null,
"client_key": null,
"content": null,
"creates": null,
"delimiter": null,
"dest": null,
"directory_mode": null,
"follow": false,
"follow_redirects": "safe",
"force": false,
"force_basic_auth": false,
"group": null,
"headers": {
"Content-Type": "application/json"
},
"http_agent": "ansible-httpget",
"method": "PATCH",
"mode": null,
"owner": null,
"regexp": null,
"remote_src": null,
"removes": null,
"return_content": false,
"selevel": null,
"serole": null,
"setype": null,
"seuser": null,
"src": null,
"status_code": [
"200"
],
"timeout": 30,
"unsafe_writes": null,
"url": "http://localhost:8001/plugins/ab7363ff-99a5-4043-a664-f6b31cb56f1a\n14c27ebc-1938-4ebf-8073-b20d366eb108\nc617d16d-8f4d-4dd4-b874-244b0167e957\nfc1b9141-162a-487e-8347-84c2e17dca8a\n308cd52c-cc4c-4851-909f-fc4d8c99c4ff\n7e99a7e1-a8e9-43b0-98e3-939a3c2c665f\nb4bee7a6-1c94-4e7f-b1a8-df1cb1a23c97\n10e543b8-4c37-48d4-864c-c7e1a665c864\n4f37bee7-105f-4439-8a4d-eb96594718e9\n983f0639-7109-4194-a370-7142c499b2ca\n58b97515-0bec-4feb-9cb7-e9f2bfc04f79\n38edc682-945c-41a9-ad5f-63dfea4a06e7\nf8f53ba3-701d-43e7-8461-41e4c96d557b\n4d1c4b46-499b-465d-a702-b01bc4314d2c\n84b64990-19d8-40f3-b4cb-3585dffc57e2\n6acb5294-db8e-463a-934e-1ac2ebc88ccc\na9be5c08-5511-4718-9d5d-824c691cbfc1\nc681069e-942c-42c5-94be-fdb02a211f51\nd0f37803-81e9-4ce1-a54d-b6a4a7c007d0\nad08250d-ec80-4af9-976a-5627017b8e0f\n8dbf537f-6558-45ba-8fbe-5f5beabecba8\n2c992df4-5a1c-4caf-be16-b6e4537bbe56\nafcbfd6d-bd5f-4bc9-b345-89d207caf3ef\n9ea42ec0-ea1c-49cf-bf65-c5eaa2580313\nd4253823-d492-46b7-8890-ae45ac250c76\n1531c69b-a031-4487-a2e4-ae02e8e7f2db\n89361b40-d111-4aa5-81e3-b43d6c5fca00",
"url_password": null,
"url_username": null,
"use_proxy": true,
"validate_certs": true
}
},
"msg": "Status code was -1 and not [200]: Request failed: <urlopen error no host given>",
"redirected": false,
"status": -1,
"url": "http://localhost:8001/plugins/ab7363ff-99a5-4043-a664-f6b31cb56f1a\n14c27ebc-1938-4ebf-8073-b20d366eb108\nc617d16d-8f4d-4dd4-b874-244b0167e957\nfc1b9141-162a-487e-8347-84c2e17dca8a\n308cd52c-cc4c-4851-909f-fc4d8c99c4ff\n7e99a7e1-a8e9-43b0-98e3-939a3c2c665f\nb4bee7a6-1c94-4e7f-b1a8-df1cb1a23c97\n10e543b8-4c37-48d4-864c-c7e1a665c864\n4f37bee7-105f-4439-8a4d-eb96594718e9\n983f0639-7109-4194-a370-7142c499b2ca\n58b97515-0bec-4feb-9cb7-e9f2bfc04f79\n38edc682-945c-41a9-ad5f-63dfea4a06e7\nf8f53ba3-701d-43e7-8461-41e4c96d557b\n4d1c4b46-499b-465d-a702-b01bc4314d2c\n84b64990-19d8-40f3-b4cb-3585dffc57e2\n6acb5294-db8e-463a-934e-1ac2ebc88ccc\na9be5c08-5511-4718-9d5d-824c691cbfc1\nc681069e-942c-42c5-94be-fdb02a211f51\nd0f37803-81e9-4ce1-a54d-b6a4a7c007d0\nad08250d-ec80-4af9-976a-5627017b8e0f\n8dbf537f-6558-45ba-8fbe-5f5beabecba8\n2c992df4-5a1c-4caf-be16-b6e4537bbe56\nafcbfd6d-bd5f-4bc9-b345-89d207caf3ef\n9ea42ec0-ea1c-49cf-bf65-c5eaa2580313\nd4253823-d492-46b7-8890-ae45ac250c76\n1531c69b-a031-4487-a2e4-ae02e8e7f2db\n89361b40-d111-4aa5-81e3-b43d6c5fca00"
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.