— Add command to generate example configuration (fix #38)

This commit is contained in:
Luc Didry 2024-05-27 14:55:32 +02:00
parent b9e2e62055
commit cb0a638545
No known key found for this signature in database
GPG key ID: EA868E12D0257E3C
5 changed files with 87 additions and 65 deletions

View file

@ -5,6 +5,7 @@
- 💄📯 — Improve notifications and result(s) pages - 💄📯 — Improve notifications and result(s) pages
- 🔊 — Add level of log before the log message - 🔊 — 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 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 ## 0.1.1

View file

@ -242,5 +242,22 @@ async def generate_token():
click.echo(uuid4()) 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__": if __name__ == "__main__":
cli() cli()

66
argos/config-example.yaml Normal file
View file

@ -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: '<div id= "mypads"></div>'
- 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

View file

@ -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: '<div id= "mypads"></div>'
- 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

1
conf/config-example.yaml Symbolic link
View file

@ -0,0 +1 @@
../argos/config-example.yaml

View file

@ -30,10 +30,10 @@ pip install -e .
## Configure ## 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 ```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). You can read more about the configuration in the [configuration section](../configuration.md).