1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

Ansible: fluent-bitの設定

Posted at

概要

Ansibleを使ってfluent-bitをRaspberryPiにインストールします。

プレイブックとテンプレート

マニュアルに書かれている通り、GPG鍵を登録してapt経由でインストールします。

fluent-bit.yaml
- name: Setup fluent-bit

  hosts: all
  become: true
  gather_facts: false
  tasks:
    - name: Add fluent-bit server’s GPG key
      ansible.builtin.apt_key:
        url: https://packages.fluentbit.io/fluentbit.key

        state: present

    - name: Add fluent-bit repository into the sources list
      ansible.builtin.apt_repository:
        repo: deb https://packages.fluentbit.io/raspbian/bullseye bullseye main
        state: present

    - name: Install fluent-bit
      ansible.builtin.apt:
        name: fluent-bit
        update_cache: true

    - name: Upload a configuration file
      ansible.builtin.template:
        src: fluent-bit.conf.j2

        dest: /etc/fluent-bit/fluent-bit.conf
        mode: "0644"

      notify:
        - config is updated

  handlers:
    - name: Restart fluent-bit
      ansible.builtin.systemd:
        name: fluent-bit
        state: restarted

      listen:
        - config is updated

  post_tasks:
    - name: Ensure fluent-bit is enabled and started
      ansible.builtin.systemd:
        name: fluent-bit

        state: started
        enabled: true

設定ファイルのテンプレート下記の通りです。タグにホスト名を追加しています。

templates/fluent-bit.conf.j2

[SERVICE]
    # Daemon
    # ======
    # instruct Fluent Bit to run in foreground or background mode.
    #
    daemon       Off

[INPUT]
    name cpu
    tag  {{ inventory_hostname_short }}.cpu
    # Read interval (sec) Default: 1
    interval_sec 1

[OUTPUT]
    name  stdout
    match *

参考

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?