|
1 | | -#!/usr/bin/env python3 |
2 | | - |
3 | | -# |
4 | | -# Copyright (C) 2022 Nethesis S.r.l. |
5 | | -# SPDX-License-Identifier: GPL-3.0-or-later |
6 | | -# |
7 | | - |
8 | | -import json |
9 | | -import sys |
10 | | -import agent |
11 | | -import agent.tasks |
12 | | -import os |
13 | | - |
14 | | -# Try to parse the stdin as JSON. |
15 | | -# If parsing fails, output everything to stderr |
16 | | -data = json.load(sys.stdin) |
17 | | - |
18 | | -# Setup default values |
19 | | -host = data.get("host") |
20 | | -h2hs = data.get("http2https", True) |
21 | | -le = data.get("lets_encrypt", False) |
22 | | - |
23 | | -# Talk with agent using file descriptor. |
24 | | -# Setup configuration from user input. |
25 | | -agent.set_env("TRAEFIK_HOST", host) |
26 | | -agent.set_env("TRAEFIK_HTTP2HTTPS", h2hs) |
27 | | -agent.set_env("TRAEFIK_LETS_ENCRYPT", le) |
28 | | - |
29 | | -# Make sure everything is saved inside the environment file |
30 | | -# just before starting systemd unit |
31 | | -agent.dump_env() |
32 | | - |
33 | | -# Find default traefik instance for current node |
34 | | -default_traefik_id = agent.resolve_agent_id('traefik@node') |
35 | | -if default_traefik_id is None: |
36 | | - sys.exit(2) |
37 | | - |
38 | | -response = agent.tasks.run( |
39 | | - agent_id=agent.resolve_agent_id('traefik@node'), |
40 | | - action='set-route', |
41 | | - data={ |
42 | | - 'instance': os.environ['MODULE_ID'], |
43 | | - 'url': 'http://127.0.0.1:' + os.environ["TCP_PORT"], |
44 | | - 'host': host, |
45 | | - 'http2https': h2hs, |
46 | | - 'lets_encrypt': le |
47 | | - }, |
48 | | -) |
49 | | - |
50 | | -# Check if traefik configuration has been successfull |
51 | | -agent.assert_exp(response['exit_code'] == 0) |
| 1 | +# Placeholder, see bug NethServer/dev#7058 |
0 commit comments