Commit b4df8a33 authored by Ivan Tyagov's avatar Ivan Tyagov

Fluent-bit: Getting SlapOS params and converting them to .cfg configuration file ...

See merge request nexedi/slapos!1276
parents 1b8b0902 63d993aa
# Fluent-bit
## When instantiating Fluent-bit you can use the following example config:
```
release="https://lab.nexedi.com/nexedi/slapos/raw/master/software/fluent-bit/software.cfg"
supply(release, "COMP-****")
partition_parameter_kw = {
"service": {
"flush": 5,
"daemon": "off",
"log_level": "debug"
},
"input": {
"name": "mqtt",
"tag": "data",
"port": 1883
},
"output": {
"name": "forward",
"match": "*",
"host": "127.0.0.1",
"port": 24224
}
}
filter_kw = {"computer_guid": "COMP-****"}
request(software_release = release, partition_reference='****', partition_parameter_kw=partition_parameter_kw, filter_kw = filter_kw)
```
[instance-profile] [instance-profile]
filename = instance.cfg.in filename = instance.cfg.in
md5sum = 6a32b81db4ea9f2f63b5a92e8a134d58 md5sum = b2845159dd53f942f32c4d4348934ce2
[buildout] [buildout]
parts = parts =
directory
fluent-bit-config-file
fluent-bit-service fluent-bit-service
eggs-directory = {{ buildout['eggs-directory'] }} eggs-directory = {{ buildout["eggs-directory"] }}
develop-eggs-directory = {{ buildout['develop-eggs-directory'] }} develop-eggs-directory = {{ buildout["develop-eggs-directory"] }}
offline = true offline = true
[instance-parameter]
recipe = slapos.cookbook:slapconfiguration
computer = ${slap-connection:computer-id}
partition = ${slap-connection:partition-id}
url = ${slap-connection:server-url}
key = ${slap-connection:key-file}
cert = ${slap-connection:cert-file}
[directory] [directory]
recipe = slapos.cookbook:mkdirectory recipe = slapos.cookbook:mkdirectory
home = ${buildout:directory} home = ${buildout:directory}
...@@ -17,8 +27,29 @@ promise = ${:etc}/promise/ ...@@ -17,8 +27,29 @@ promise = ${:etc}/promise/
log = ${:var}/log log = ${:var}/log
bin = ${:home}/bin bin = ${:home}/bin
[fluent-bit-config-file]
recipe = slapos.recipe.build
location = ${directory:etc}/${:_buildout_section_name_}.cfg
ip = ${instance-parameter:ipv4-random}
install =
config = open(self.options["location"], "w")
ip = self.options["ip"]
input = ${instance-parameter:configuration.input}
output = ${instance-parameter:configuration.output}
config.write(f"[INPUT]\n")
for key in input:
config.write(f" {str(key).capitalize()} {input[key]}\n")
config.write(f" Listen {ip}\n")
config.write("\n")
config.write(f"[OUTPUT]\n")
for key in output:
config.write(f" {str(key).capitalize()} {output[key]}\n")
[fluent-bit-service] [fluent-bit-service]
recipe = slapos.cookbook:wrapper recipe = slapos.cookbook:wrapper
command-line = {{ fluent_bit_location }}/bin/fluent-bit -i cpu -o stdout command-line = {{ fluent_bit_location }}/bin/fluent-bit -c ${fluent-bit-config-file:location}
wrapper-path = ${directory:service}/fluentbit-service wrapper-path = ${directory:service}/fluentbit-service
output = $${:wrapper-path} output = $${:wrapper-path}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment