Skip to content
This repository was archived by the owner on Apr 12, 2022. It is now read-only.

Added support for Beats modules #132

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ logging_conf: {"files":{"rotateeverybytes":10485760}}
output_conf: {"elasticsearch":{"hosts":["localhost:9200"]}}
beats_pid_dir: "/var/run"
beats_conf_dir: "/etc/{{beat}}"
beats_modules_dir: "/etc/{{beat}}/modules.d"
12 changes: 12 additions & 0 deletions tasks/beats-config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,3 +86,15 @@
group: root
when: default_ilm_policy is defined
notify: restart the service

- name: Assert modules.path presence
assert:
that:
- beat_conf.{{beat}}.config.modules.path is defined
fail_msg: 'You need to configure beat_conf.{{beat}}.config.modules.path for modules to be loaded'
when: beat_modules is defined

- name: Set up and configure modules
include_tasks: beats-modules.yml
with_dict: "{{ beat_modules }}"
when: beat_modules is defined
24 changes: 24 additions & 0 deletions tasks/beats-modules.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
- name: Disable modules
become: yes
file:
path: "{{ beats_modules_dir }}/{{ item.key }}.yml"
state: absent
when: item.value.enabled is defined and not item.value.enabled
notify: restart the service

- name: Enable modules with default config
become: yes
copy:
remote_src: yes
src: "{{ beats_modules_dir }}/{{ item.key }}.yml.disabled"
dest: "{{ beats_modules_dir }}/{{ item.key }}.yml"
when: (not item.value.enabled is defined or item.value.enabled) and not item.value.config is defined
notify: restart the service

- name: Set up modules with custom config
become: yes
copy:
content: "{{ item.value.config | to_nice_yaml(indent=2) }}"
dest: "{{ beats_modules_dir }}/{{ item.key }}.yml"
when: (not item.value.enabled is defined or item.value.enabled) and item.value.config is defined
notify: restart the service