darexsu.filebeat

Ansible role: Filebeat

CI Molecule  Ansible Role

Platforms

Testing repo: elastic
Debian 11 elastic.co
Debian 10 elastic.co
Ubuntu 20.04 elastic.co
Ubuntu 18.04 elastic.co
Oracle Linux 8 elastic.co
Rocky Linux 8 elastic.co

Install

ansible-galaxy install darexsu.filebeat --force

Merge behaviour

Replace or Merge dictionaries (with "hash_behaviour=replace" in ansible.cfg):

# Replace             # Merge
---                   ---
  vars:                 vars:
    dict:                 merge:
      a: "value"            dict: 
      b: "value"              a: "value" 
                              b: "value"

# How does merge work?:
Your vars [host_vars]  -->  default vars [current role] --> default vars [include role]
  
  dict:          dict:              dict:
    a: "1" -->     a: "1"    -->      a: "1"
                   b: "2"    -->      b: "2"
                                      c: "3"
    
Install and configure: Filebeat (merge version)
---
- hosts: all
  become: true

  vars:
    merge:
      # Filebeat
      filebeat:
        enabled: true
      # Filebeat -> install
      filebeat_install:
        enabled: true
      # Filebeat -> config -> filebeat.yml
      filebeat_yml:
        enabled: true
        data: |
          # ============================== Filebeat inputs ===============================
          filebeat.inputs:
            - type: filestream
              enabled: true
              paths:
                - /var/log/*.log
          # ============================== Filebeat modules ==============================
          filebeat.config.modules:
            path: ${path.config}/modules.d/*.yml
            reload.enabled: false
          # ======================= Elasticsearch template setting =======================
          setup.template.settings:
            index.number_of_shards: 1
          # ================================== General ===================================
          setup.kibana:
          # ---------------------------- Elasticsearch Output ----------------------------
          # output.elasticsearch:
          #   hosts: ["localhost:9200"]
          # ------------------------------ Logstash Output -------------------------------
          output.logstash:
            hosts: ["localhost:5044"]
          # ================================= Processors =================================
          processors:
            - add_host_metadata:
                when.not.contains.tags: forwarded
            - add_cloud_metadata: ~
            - add_docker_metadata: ~
            - add_kubernetes_metadata: ~
          # ================================== Logging ===================================
          # logging.level: debug
          # logging.selectors: ["*"]
          # ============================= X-Pack Monitoring ==============================
          # monitoring.enabled: false
          # monitoring.cluster_uuid:
          # monitoring.elasticsearch:
          # ============================== Instrumentation ===============================
          # instrumentation:
          # enabled: false
          # environment: ""
          # hosts:
          #   - http://localhost:8200
          # api_key:
          # secret_token:
          # ================================= Migration ==================================
          # migration.6_to_7.enabled: true

  tasks:
    - name: role darexsu filebeat
      include_role:
        name: darexsu.filebeat
Install: Filebeat (merge version)
---
- hosts: all
  become: true

  vars:
    merge:
      # Filebeat
      filebeat:
        enabled: true
      # Filebeat -> install
      filebeat_install:
        enabled: true

  tasks:
    - name: role darexsu filebeat
      include_role:
        name: darexsu.filebeat
Configure: Filebeat (merge version)
---
- hosts: all
  become: true

  vars:
    merge:
      # Filebeat
      filebeat:
        enabled: true
      # Filebeat -> config -> filebeat.yml
      filebeat_yml:
        enabled: true
        data: |
          # ============================== Filebeat inputs ===============================
          filebeat.inputs:
            - type: filestream
              enabled: true
              paths:
                - /var/log/*.log
          # ============================== Filebeat modules ==============================
          filebeat.config.modules:
            path: ${path.config}/modules.d/*.yml
            reload.enabled: false
          # ======================= Elasticsearch template setting =======================
          setup.template.settings:
            index.number_of_shards: 1
          # ================================== General ===================================
          setup.kibana:
          # ---------------------------- Elasticsearch Output ----------------------------
          # output.elasticsearch:
          #   hosts: ["localhost:9200"]
          # ------------------------------ Logstash Output -------------------------------
          output.logstash:
            hosts: ["localhost:5044"]
          # ================================= Processors =================================
          processors:
            - add_host_metadata:
                when.not.contains.tags: forwarded
            - add_cloud_metadata: ~
            - add_docker_metadata: ~
            - add_kubernetes_metadata: ~
          # ================================== Logging ===================================
          # logging.level: debug
          # logging.selectors: ["*"]
          # ============================= X-Pack Monitoring ==============================
          # monitoring.enabled: false
          # monitoring.cluster_uuid:
          # monitoring.elasticsearch:
          # ============================== Instrumentation ===============================
          # instrumentation:
          # enabled: false
          # environment: ""
          # hosts:
          #   - http://localhost:8200
          # api_key:
          # secret_token:
          # ================================= Migration ==================================
          # migration.6_to_7.enabled: true

  tasks:
    - name: role darexsu filebeat
      include_role:
        name: darexsu.filebeat

Install and configure: Filebeat (full version)
---
- hosts: all
  become: true

  vars:
    # Filebeat
    filebeat:
      enabled: true
      version: "8.x"
      repo: "elastic"
      service:
        enabled: true
        state: "started"
    # Filebeat -> install
    filebeat_install:
      enabled: true
      
    # Filebeat -> config -> filebeat.yml
    filebeat_yml:
      enabled: true
      file: "filebeat.yml"
      src: "filebeat_yml.j2"
      backup: false
      data: |
        # ============================== Filebeat inputs ===============================
        filebeat.inputs:
          - type: filestream
            enabled: true
            paths:
              - /var/log/*.log
        # ============================== Filebeat modules ==============================
        filebeat.config.modules:
          path: ${path.config}/modules.d/*.yml
          reload.enabled: false
        # ======================= Elasticsearch template setting =======================
        setup.template.settings:
          index.number_of_shards: 1
        # ================================== General ===================================
        setup.kibana:
        # ---------------------------- Elasticsearch Output ----------------------------
        # output.elasticsearch:
        #   hosts: ["localhost:9200"]
        # ------------------------------ Logstash Output -------------------------------
        output.logstash:
          hosts: ["localhost:5044"]
        # ================================= Processors =================================
        processors:
          - add_host_metadata:
              when.not.contains.tags: forwarded
          - add_cloud_metadata: ~
          - add_docker_metadata: ~
          - add_kubernetes_metadata: ~
        # ================================== Logging ===================================
        # logging.level: debug
        # logging.selectors: ["*"]
        # ============================= X-Pack Monitoring ==============================
        # monitoring.enabled: false
        # monitoring.cluster_uuid:
        # monitoring.elasticsearch:
        # ============================== Instrumentation ===============================
        # instrumentation:
        # enabled: false
        # environment: ""
        # hosts:
        #   - http://localhost:8200
        # api_key:
        # secret_token:
        # ================================= Migration ==================================
        # migration.6_to_7.enabled: true

  tasks:
    - name: role darexsu filebeat
      include_role:
        name: darexsu.filebeat
Install: Filebeat (full version)
---
- hosts: all
  become: true

  vars:
    # Filebeat
    filebeat:
      enabled: true
      version: "8.x"
      repo: "elastic"
      service:
        enabled: true
        state: "started"
    # Filebeat -> install
    filebeat_install:
      enabled: true

  tasks:
    - name: role darexsu filebeat
      include_role:
        name: darexsu.filebeat
Configure: Filebeat (full version)
---
- hosts: all
  become: true

  vars:    
    # Filebeat
    filebeat:
      enabled: true
      version: "8.x"
      repo: "elastic"
      service:
        enabled: true
        state: "started"
    # Filebeat -> config -> filebeat.yml
    filebeat_yml:
      enabled: true
      file: "filebeat.yml"
      src: "filebeat_yml.j2"
      backup: false
      data: |
        # ============================== Filebeat inputs ===============================
        filebeat.inputs:
          - type: filestream
            enabled: true
            paths:
              - /var/log/*.log
        # ============================== Filebeat modules ==============================
        filebeat.config.modules:
          path: ${path.config}/modules.d/*.yml
          reload.enabled: false
        # ======================= Elasticsearch template setting =======================
        setup.template.settings:
          index.number_of_shards: 1
        # ================================== General ===================================
        setup.kibana:
        # ---------------------------- Elasticsearch Output ----------------------------
        # output.elasticsearch:
        #   hosts: ["localhost:9200"]
        # ------------------------------ Logstash Output -------------------------------
        output.logstash:
          hosts: ["localhost:5044"]
        # ================================= Processors =================================
        processors:
          - add_host_metadata:
              when.not.contains.tags: forwarded
          - add_cloud_metadata: ~
          - add_docker_metadata: ~
          - add_kubernetes_metadata: ~
        # ================================== Logging ===================================
        # logging.level: debug
        # logging.selectors: ["*"]
        # ============================= X-Pack Monitoring ==============================
        # monitoring.enabled: false
        # monitoring.cluster_uuid:
        # monitoring.elasticsearch:
        # ============================== Instrumentation ===============================
        # instrumentation:
        # enabled: false
        # environment: ""
        # hosts:
        #   - http://localhost:8200
        # api_key:
        # secret_token:
        # ================================= Migration ==================================
        # migration.6_to_7.enabled: true

  tasks:
    - name: role darexsu filebeat
      include_role:
        name: darexsu.filebeat
About

install and configure filebeat

Install
ansible-galaxy install darexsu.filebeat
GitHub repository
License
mit
Downloads
782
Owner