From cb0a638545449eaf1a31866b693e8810db713eab Mon Sep 17 00:00:00 2001 From: Luc Didry Date: Mon, 27 May 2024 14:55:32 +0200 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20=E2=80=94=20Add=20command=20to=20ge?= =?UTF-8?q?nerate=20example=20configuration=20(fix=20#38)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 1 + argos/commands.py | 17 +++++++ argos/config-example.yaml | 66 ++++++++++++++++++++++++++++ conf/config-example.yaml | 64 +-------------------------- docs/installation/getting-started.md | 4 +- 5 files changed, 87 insertions(+), 65 deletions(-) create mode 100644 argos/config-example.yaml mode change 100644 => 120000 conf/config-example.yaml diff --git a/CHANGELOG.md b/CHANGELOG.md index d452ff3..6db89ab 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ - 💄📯 — Improve notifications and result(s) pages - 🔊 — Add level of log before the log message — 🔊 — Add a warning messages in the logs if there is no tasks in database. (fix #41) +- ✨ — Add command to generate example configuration (fix #38) ## 0.1.1 diff --git a/argos/commands.py b/argos/commands.py index 2b822b7..51e9f95 100644 --- a/argos/commands.py +++ b/argos/commands.py @@ -242,5 +242,22 @@ async def generate_token(): click.echo(uuid4()) +@server.command() +@coroutine +async def generate_config(): + """Output an example config file. + + \b + Redirect the output to a file to save it: + argos server generate-config > /etc/argos/config.yaml + """ + current_dir = os.path.dirname(__file__) + with open( + os.path.join(current_dir, "config-example.yaml"), "r", encoding="utf-8" + ) as f: + print(f.read()) + f.close() + + if __name__ == "__main__": cli() diff --git a/argos/config-example.yaml b/argos/config-example.yaml new file mode 100644 index 0000000..d36ad85 --- /dev/null +++ b/argos/config-example.yaml @@ -0,0 +1,66 @@ +general: + frequency: "1m" # Run checks every minute. + # Which way do you want to be warned when a check goes to that severity? + # "local" emits a message in the server log + alerts: + ok: + - local + warning: + - local + critical: + - local + unknown: + - local +# mail: +# mailfrom: no-reply@example.org +# host: 127.0.0.1 +# port: 25 +# ssl: False +# starttls: False +# auth: +# login: foo +# password: bar +# addresses: +# - foo@admin.example.org +# - bar@admin.example.org +# gotify: +# - url: https://example.org +# tokens: +# - foo +# - bar + +service: + secrets: + # Secrets can be generated using `argos server generate-token`. + # You need at least one. Write them as a list, like: + # - secret_token + +ssl: + thresholds: + - "1d": critical + - "5d": warning + +# It's also possible to define the checks in another file +# with the include syntax: +# +# websites: !include websites.yaml +# +websites: + - domain: "https://mypads.example.org" + paths: + - path: "/mypads/" + checks: + - status-is: 200 + - body-contains: '
' + - ssl-certificate-expiration: "on-check" + - path: "/admin/" + checks: + - status-is: 401 + - domain: "https://munin.example.org" + paths: + - path: "/" + checks: + - status-is: 301 + - path: "/munin/" + checks: + - status-is: 401 diff --git a/conf/config-example.yaml b/conf/config-example.yaml deleted file mode 100644 index 8bbf908..0000000 --- a/conf/config-example.yaml +++ /dev/null @@ -1,63 +0,0 @@ -general: - frequency: "1m" # Run checks every minute. - # Which way do you want to be warned when a check goes to that severity? - alerts: - ok: - - local - warning: - - local - critical: - - local - unknown: - - local -# mail: -# mailfrom: no-reply@example.org -# host: 127.0.0.1 -# port: 25 -# ssl: False -# starttls: False -# auth: -# login: foo -# password: bar -# addresses: -# - foo@admin.example.org -# - bar@admin.example.org -# gotify: -# - url: https://example.org -# tokens: -# - foo -# - bar - -service: - secrets: - # Secrets can be generated using `openssl rand -base64 32`. - -ssl: - thresholds: - - "1d": critical - - "5d": warning - -# It's also possible to define the checks in another file -# with the include syntax: -# -# websites: !include websites.yaml -# -websites: - - domain: "https://mypads.example.org" - paths: - - path: "/mypads/" - checks: - - status-is: 200 - - body-contains: '
' - - ssl-certificate-expiration: "on-check" - - path: "/admin/" - checks: - - status-is: 401 - - domain: "https://munin.example.org" - paths: - - path: "/" - checks: - - status-is: 301 - - path: "/munin/" - checks: - - status-is: 401 diff --git a/conf/config-example.yaml b/conf/config-example.yaml new file mode 120000 index 0000000..52bab49 --- /dev/null +++ b/conf/config-example.yaml @@ -0,0 +1 @@ +../argos/config-example.yaml \ No newline at end of file diff --git a/docs/installation/getting-started.md b/docs/installation/getting-started.md index 5f784eb..e65eeec 100644 --- a/docs/installation/getting-started.md +++ b/docs/installation/getting-started.md @@ -30,10 +30,10 @@ pip install -e . ## Configure -The quickest way to get started is to get the `config-example.yaml` file from our repository and edit it: +The quickest way to get started is to generate the configuration file from argos and edit it: ```bash -wget https://framagit.org/framasoft/framaspace/argos/-/raw/main/conf/config-example.yaml -O config.yaml +argos server generate-config > config.yaml ``` You can read more about the configuration in the [configuration section](../configuration.md).