diff --git a/README.rst b/README.rst index 0e6bbed..ccbbde2 100644 --- a/README.rst +++ b/README.rst @@ -36,18 +36,32 @@ Configures the fluent-bit service with upstart/systemd etc Configures fluent-bit input/output plugins +``fluent-bit.repo`` +-------------------- + +Configures the Fluent Bit repository to install packages from. +Currently works with Debian/Ubuntu and RedHat family (RHEL, CentOS, Rocky, Alma, etc.). + + +``fluent-bit.repo.clean`` +-------------------- + +Removes the Fluent Bit repository from repositories list. + + TODO: ================ -- Add repository install +- Expand repository install to support all distributions available in official repository. - Prepare next gen with (will break old format): - `` - bit: - fluent-bit: - config: - flush: 5 - bit: - td-agent-bit: - config: - flush: 5 - `` \ No newline at end of file + +.. code-block:: + + bit: + fluent-bit: + config: + flush: 5 + bit: + td-agent-bit: + config: + flush: 5 diff --git a/fluent-bit/defaults.yaml b/fluent-bit/defaults.yaml index 4d95ea5..86dd800 100644 --- a/fluent-bit/defaults.yaml +++ b/fluent-bit/defaults.yaml @@ -3,6 +3,8 @@ fluent_bit: pkg: fluent-bit + repo: + keyring: '/usr/share/keyrings/fluentbit-keyring.gpg' service: unit: '/lib/systemd/system/fluent-bit.service' conf: '/etc/td-agent-bit/fluent-bit.conf' diff --git a/fluent-bit/repo/clean.sls b/fluent-bit/repo/clean.sls new file mode 100644 index 0000000..9d3fb7f --- /dev/null +++ b/fluent-bit/repo/clean.sls @@ -0,0 +1,19 @@ +# -*- coding: utf-8 -*- +# vim: ft=sls + +{% from "fluent-bit/map.jinja" import bit with context %} + +{{ bit.pkg }}_repo-absent: +{%- if salt['grains.get']('os_family') == 'RedHat' %} + pkgrepo.absent: + - name: {{ bit.pkg }} + +{%- elif salt['grains.get']('os_family') == 'Debian' %} + file.absent: + - name: /etc/apt/sources.list.d/{{ bit.pkg }}.list + +{{ bit.pkg }}_repo-keyring-absent: + file.absent: + - name: {{ bit.repo.keyring }} + +{%- endif %} diff --git a/fluent-bit/repo/fluentbit-keyring.gpg b/fluent-bit/repo/fluentbit-keyring.gpg new file mode 100644 index 0000000..f3a13d2 Binary files /dev/null and b/fluent-bit/repo/fluentbit-keyring.gpg differ diff --git a/fluent-bit/repo/init.sls b/fluent-bit/repo/init.sls new file mode 100644 index 0000000..d3e5518 --- /dev/null +++ b/fluent-bit/repo/init.sls @@ -0,0 +1,5 @@ +# -*- coding: utf-8 -*- +# vim: ft=sls + +include: + - .install diff --git a/fluent-bit/repo/install.sls b/fluent-bit/repo/install.sls new file mode 100644 index 0000000..296f382 --- /dev/null +++ b/fluent-bit/repo/install.sls @@ -0,0 +1,37 @@ +# -*- coding: utf-8 -*- +# vim: ft=sls + +{% from "fluent-bit/map.jinja" import bit with context %} + +{% if salt['grains.get']('os_family') == 'Debian' -%} + +{{ bit.pkg }}_apt-transport-https: + pkg.installed: + - name: apt-transport-https + +{{ bit.pkg }}_keyring: + file.managed: + - name: {{ bit.repo.keyring }} + - source: salt://{{ slspath }}/fluentbit-keyring.gpg + - require_in: + - pkgrepo: {{ bit.pkg }}_repo + +{{ bit.pkg }}_repo: + pkgrepo.managed: + - name: deb [ arch={{ grains.osarch }} signedby={{ bit.repo.keyring }} ] + https://packages.fluentbit.io/{{ grains.os|lower }}/{{ grains.oscodename }} {{ grains.oscodename }} main + - file: /etc/apt/sources.list.d/{{ bit.pkg }}.list + - clean_file: True + +{% elif salt['grains.get']('os_family') == 'RedHat' %} + +{{ bit.pkg }}_repo: + pkgrepo.managed: + - name: {{ bit.pkg }} + - humanname: Fluent Bit + - baseurl: https://packages.fluentbit.io/centos/$releasever/{{ grains.osarch }}/ + - gpgcheck: 1 + - gpgkey: https://packages.fluentbit.io/fluentbit.key + - gpgautoimport: True + +{% endif %}