From 492b7ddf2a7ea8d5cd459372315e143bb96990fb Mon Sep 17 00:00:00 2001 From: lza_menace Date: Mon, 15 Nov 2021 10:16:08 -0800 Subject: [PATCH] adding new api route to use dynamic nginx upstreams --- app/routes/api.py | 11 +++++++++++ app/templates/export_upstreams.html | 5 +++++ 2 files changed, 16 insertions(+) create mode 100644 app/templates/export_upstreams.html diff --git a/app/routes/api.py b/app/routes/api.py index a610150..bffd770 100644 --- a/app/routes/api.py +++ b/app/routes/api.py @@ -25,3 +25,14 @@ def export_ansible(): ops=ops, domain=config.DO_DOMAIN ) + +@bp.route('/api/export/upstreams') +def export_upstreams(): + ops = Operation.query.filter( + Operation.droplet_id > 0 + ) + return render_template( + 'export_upstreams.html', + ops=ops, + domain=config.DO_DOMAIN + ) diff --git a/app/templates/export_upstreams.html b/app/templates/export_upstreams.html new file mode 100644 index 0000000..465a2fa --- /dev/null +++ b/app/templates/export_upstreams.html @@ -0,0 +1,5 @@ +upstream xmrnodes { + {% for op in ops %} + server {{ op.codename }}.node.{{ domain }}:18081 max_fails=3 fail_timeout=5s; + {% endfor %} +}