Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
a8a5ca1
parameterize cluster user privs
crosmuller Nov 21, 2025
c0064a6
make filebeat role working for our real environment
crosmuller Jun 24, 2026
77695e4
default min privileges
crosmuller Jun 24, 2026
db1b317
minimal privileges sst_user
crosmuller Jun 24, 2026
f1622c5
fix indentationa nd warn non debian users
crosmuller Jun 25, 2026
b2b7bfb
fix handler
crosmuller Jun 25, 2026
28ced0e
make services work with simple config
crosmuller Jul 1, 2026
a965c7d
use target file
crosmuller Jul 1, 2026
b6fde6d
use target file
crosmuller Jul 1, 2026
63e0d00
add todo
crosmuller Jul 1, 2026
16dc596
sst user privs add super
crosmuller Jul 1, 2026
07012ad
real config
crosmuller Jul 1, 2026
5c60295
use real binary
crosmuller Jul 1, 2026
d322325
deploy certificate
crosmuller Jul 1, 2026
37268e9
temporarily disable services
crosmuller Jul 2, 2026
7560289
enable services
crosmuller Jul 2, 2026
00d55d3
Merge branch 'feature/filebeat' into release/679
crosmuller Jul 2, 2026
12309c3
binlog monitor is the new name for replication client
crosmuller Jul 3, 2026
0c9823b
Merge branch 'main' into release/679
crosmuller Jul 13, 2026
c4a00da
add certificate path
crosmuller Jul 16, 2026
a3cf498
disable services
crosmuller Jul 16, 2026
59629a8
filebeat downgrade
crosmuller Jul 27, 2026
f2cb5c2
major version is enough
crosmuller Jul 27, 2026
04c2812
fields is a dict not a list
crosmuller Jul 29, 2026
8c771e3
deprecated use is no longer relevant
crosmuller Jul 29, 2026
8db3e45
only works with square brackets
crosmuller Jul 29, 2026
a75f526
enable services
crosmuller Jul 29, 2026
37091e4
disable services
crosmuller Jul 29, 2026
38a9f3a
enable services
crosmuller Jul 29, 2026
6271c55
Merge branch 'main' into release/679
crosmuller Jul 30, 2026
5d49b0d
add gpg key
crosmuller Aug 5, 2026
71a48dc
copy gpg key
crosmuller Aug 5, 2026
fcc00f6
Merge branch 'main' into release/679
crosmuller Aug 5, 2026
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
2 changes: 2 additions & 0 deletions roles/filebeat/TODO.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- deploy certificates
- fix warnings
22 changes: 20 additions & 2 deletions roles/filebeat/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,20 @@
filebeat_tls: False
filebeat_eblog: False
filebeat_tls: false
filebeat_eblog: false
filebeat_major_version: 7
filebeat_apt_url: "https://artifacts.elastic.co/packages/oss-{{ filebeat_major_version }}.x/apt"
# add instances to group or host vars:
# filebeat_instances:
# - name: filebeat_sc_prd
# description: "Filebeat instance to send logs to logstash" # description for systemd unit file
# logpaths:
# - "/opt/openconext/logs/apps/prod_sc/eb/eb.log"
# - "/opt/openconext/logs/log_logins/prod_sc/eb-authentication.log"
# fields:
# - "env: prod_sc"
# logstash_hosts: '["logstashserver.example.com:5044","logstashserver2.example.com:5044"]'
# logstash_ca_path: "/etc/pki/tls/certs"
# logstash_ca: "{{ logstash_ca_path }}/logstash-prod-ca.pem"
# cacert_content: |
# -----BEGIN CERTIFICATE-----
# MIIEKzCCAxOgAwIBAgIJAMjE1SXBf9RJMA0GCSqGSIb3DQEBBQUAMIGqMQswCQYD
# VQQGEwJOTDEQMA4GA1UECAwHVXRyZWNodDEQMA4GA1UEBwwHVXRyZWNodDEVMBMG
31 changes: 31 additions & 0 deletions roles/filebeat/files/GPG-KEY-elasticsearch
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
-----BEGIN PGP PUBLIC KEY BLOCK-----

mQENBFI3HsoBCADXDtbNJnxbPqB1vDNtCsqhe49vFYsZN9IOZsZXgp7aHjh6CJBD
A+bGFOwyhbd7at35jQjWAw1O3cfYsKAmFy+Ar3LHCMkV3oZspJACTIgCrwnkic/9
CUliQe324qvObU2QRtP4Fl0zWcfb/S8UYzWXWIFuJqMvE9MaRY1bwUBvzoqavLGZ
j3SF1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VP1jNJLNCsMBMEpP1A7k6MRpylNnUAEQEAAYkBNgQYAQgA
IAIbDBYhBEYJWsyFSFgsGiaZqdJ9ZmzYjkK0BQJk9vsHAAoJENJ9ZmzYjkK0hWsH
/ArKtn12HM3+41zYo9qO4rTri7+IYTjSB/JDTOusZgZLd/HCp1xQo4SI2Eur3Rtx
USMWK1LEeBzsjwDT9yVceYekrBEqUVyRMSVYj+UeZK2s4LbXm9b4jxXVtaivmkMA
jtznndrD7kmm8ak+UsZplf6p6uZS9TZ9hjwoMmw5oMaS6TZkLT4KYGWeyzHJSUBX
YikY6vssDQu4SJ07m1f4Hz81J39QOcHln5I5HTK8Rh/VUFcxNnGg9360g55wWpiF
eUTeMyoXpOtffiUhiOtbRYsmSYC0D4Fd5yJnO3n1pwnVVVsM7RAC22rc5j/Dw8dR
GIHikRcYWeXTYW7veewK5Ss=
=ftS0
-----END PGP PUBLIC KEY BLOCK-----
10 changes: 8 additions & 2 deletions roles/filebeat/handlers/main.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
---
- name: restart filebeat
service: name=filebeat state=restarted
- name: Restart filebeat
ansible.builtin.service:
name: filebeat_all.target
state: restarted

- name: Reload systemd
ansible.builtin.systemd_service:
daemon_reload: true
152 changes: 134 additions & 18 deletions roles/filebeat/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,25 +1,141 @@
---
- name: Add Elasticsearch GPG key.
rpm_key:
key: http://packages.elasticsearch.org/GPG-KEY-elasticsearch
state: present

- name: Add elasticsearch yum repo
copy:
src: elasticsearch.repo
dest: /etc/yum.repos.d/elasticsearch.repo
mode: 0644
- name: "/etc/Message for non redhat family servers"
when: ansible_facts['os_family'] != 'Debian'
ansible.builtin.fail:
msg: "Sorry, this role only works on Debian family servers"

- name: Install Filebeat
yum: name=filebeat state=present
- name: "Install filebeat on Debian"
when: ansible_facts["os_family"] == "Debian"
block:

#- name: Install cacert certificate
#copy: src={{ inventory_dir }}/files/certs/elastic_ca.pem dest=/etc/pki/elastic/
- name: "Gather installed package facts"
ansible.builtin.package_facts:
manager: "apt"

- name: Install filebeat.yml
template: src=filebeat.yml.j2 dest=/etc/filebeat/filebeat.yml
- name: "Determine if Filebeat install is needed"
ansible.builtin.set_fact:
filebeat_install_needed: "{{ 'filebeat' not in ansible_facts.packages }}"

- name: "Install or upgrade filebeat when it is not installed already"
when: filebeat_install_needed
block:
- name: "Debug ansible facts packages"
ansible.builtin.debug:
msg: "ansible facts packages: {{ ansible_facts.packages }}"
verbosity: 3

- name: "Debug file install needed"
ansible.builtin.debug:
msg: "filebeat_install_needed: {{ filebeat_install_needed }}"
verbosity: 2

- name: "Ensure keyrings directory exists"
ansible.builtin.file:
path: "/etc/apt/keyrings"
state: "directory"
mode: '0755'

- name: "Copy Elasticsearch GPG key"
ansible.builtin.copy:
src: "/files/GPG-KEY-elasticsearch"
dest: "/tmp/GPG-KEY-elasticsearch"
mode: '0644'
Comment thread
crosmuller marked this conversation as resolved.

- name: "Dearmor and install Elasticsearch GPG key"
ansible.builtin.command: gpg --dearmor -o /etc/apt/keyrings/elasticsearch.gpg /tmp/GPG-KEY-elasticsearch
args:
creates: "/etc/apt/keyrings/elasticsearch.gpg"

- name: "Add Elasticsearch repository"
ansible.builtin.template:
src: "elastic.list.j2"
dest: "/etc/apt/sources.list.d/elastic.list"
mode: '0644'

- name: "Update the repository cache and install filebeat"
ansible.builtin.apt:
name: "filebeat"
state: "present"
update_cache: true

- name: "Create configuration directories for all instances"
ansible.builtin.file:
path: "/etc/{{ item.name }}"
state: "directory"
owner: "root"
group: "root"
mode: "0755"
loop: "{{ filebeat_instances }}"

- name: "Create configuration files for all instances"
ansible.builtin.template:
dest: "/etc/{{ item.name }}/filebeat.yml"
src: "filebeat.yml.j2"
owner: "root"
group: "root"
mode: "0644"
loop: "{{ filebeat_instances }}"
notify: "Restart filebeat"

- name: "Create pem directory if necessary"
ansible.builtin.file:
dest: "{{ item.logstash_ca_path }}"
state: "directory"
owner: "root"
group: "root"
mode: "0755"
loop: "{{ filebeat_instances }}"
when: item.logstash_ca_path is defined

- name: "Create pem file if necessary"
ansible.builtin.template:
dest: "{{ item.logstash_ca }}"
src: "ca_cert.j2"
owner: "root"
group: "root"
mode: "0644"
loop: "{{ filebeat_instances }}"
when: item.logstash_ca is defined
notify: "Restart filebeat"

- name: "Create custom systemd files in /etc/systemd/system"
ansible.builtin.template:
dest: "/etc/systemd/system/{{ item.name }}.service"
src: "filebeat.item.service.j2"
owner: "root"
group: "root"
mode: "0755"
loop: "{{ filebeat_instances }}"
notify:
- restart filebeat
- "Restart filebeat"
- "Reload systemd"

- name: "Create systemd file in /etc/systemd/system for managing all filebeat services"
ansible.builtin.template:
dest: "/etc/systemd/system/filebeat_all.target"
src: "filebeat.target.j2"
owner: "root"
group: "root"
mode: "0644"
notify:
- "Restart filebeat"
- "Reload systemd"

- name: "Disable and stop service filebeat" # Because we have custom instances
ansible.builtin.service:
name: "filebeat"
state: "stopped"
enabled: false

- name: Enable filebeat instances services
ansible.builtin.service:
name: "{{ item.name }}"
enabled: true
loop: "{{ filebeat_instances }}"

- name: Enable and start filebeat
service: name=filebeat state=started enabled=yes
- name: Enable and start service filebeat_all
ansible.builtin.service:
name: filebeat_all.target
state: started
enabled: true
1 change: 1 addition & 0 deletions roles/filebeat/templates/ca_cert.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{{ item.cacert_content | default ("") }}
1 change: 1 addition & 0 deletions roles/filebeat/templates/elastic.list.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
deb [signed-by=/etc/apt/keyrings/elasticsearch.gpg] {{ filebeat_apt_url }} stable main
14 changes: 14 additions & 0 deletions roles/filebeat/templates/filebeat.item.service.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[Unit]
Description={{ item.description }}
Documentation=https://www.elastic.co/products/beats/filebeat
PartOf=filebeat_all.target

[Service]
Environment="BEAT_LOG_OPTS=-e"
Environment="BEAT_CONFIG_OPTS=-c /etc/{{ item.name }}/filebeat.yml"
Environment="BEAT_PATH_OPTS=--path.home /usr/share/filebeat --path.config /etc/{{ item.name }} --path.data /var/lib/{{ item.name }} --path.logs /var/log/{{ item.name }}"
ExecStart=/usr/share/filebeat/bin/filebeat $BEAT_LOG_OPTS $BEAT_CONFIG_OPTS $BEAT_PATH_OPTS
Restart=always

[Install]
WantedBy=filebeat_all.target
6 changes: 6 additions & 0 deletions roles/filebeat/templates/filebeat.target.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[Unit]
Description=Filebeat services group
After=network.target

[Install]
WantedBy=multi-user.target
53 changes: 32 additions & 21 deletions roles/filebeat/templates/filebeat.yml.j2
Original file line number Diff line number Diff line change
@@ -1,29 +1,40 @@
filebeat.prospectors:
# filebeat.inputs:
# - type: log
# allow_deprecated_use: true
# enabled: true
# paths:
# - /var/log/*.log
#
# output.file:
# path: "/tmp/filebeat-output"
# filename: filebeat.json

{% if filebeat_eblog %}
filebeat.inputs:
- type: log
paths:
- /var/log/messages
include_lines: ["EBLOG"]
fields:
prog: EBLOG
env: {{ env }}
fields_under_root: true
{% endif %}
{%- for logpath in item.logpaths %}

- {{ logpath -}}
{% endfor %}

- type: log
paths:
- /var/log/messages
include_lines: ['EBAUTH']
exclude_lines: ['influxd']
fields:
prog: EBAUTH
env: {{ env }}
fields_under_root: true
{%- for field in item.fields %}

{{ field -}}
{% endfor %}

fields_under_root: true
filebeat.config.modules:
path: ${path.config}/modules.d/*.yml
reload.enabled: false
setup.template.settings:
index.number_of_shards: 1
setup.kibana:
processors:
- drop_fields:
fields: ["host"]
output.logstash:
hosts: ["logstash.{{ base_domain }}:5044"]
{% if filebeat_tls %}
ssl.certificate_authorities: ["/etc/pki/filebeat/filebeat_ca.pem"]
{% endif %}
hosts: {{ item.logstash_hosts }}
{% if item.logstash_ca is defined %}
ssl.certificate_authorities: ["{{ item.logstash_ca }}"]
{% endif %}
2 changes: 1 addition & 1 deletion roles/galera/tasks/cluster_nodes.yml
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@
mysql_user:
name: "{{ mariadb_cluster_user }}"
password: "{{ mariadb_cluster_password }}"
priv: "{{ mariadb_cluster_user_privs | default('*.*:RELOAD,PROCESS,LOCK TABLES,BINLOG MONITOR,SLAVE MONITOR') }}"
priv: "{{ mariadb_cluster_user_privs | default('*.*:RELOAD, PROCESS, LOCK TABLES, BINLOG MONITOR, SUPER') }}"
state: present
Comment thread
crosmuller marked this conversation as resolved.
login_user: root
login_password: "{{ mariadb_root_password }}"
Expand Down
18 changes: 10 additions & 8 deletions roles/rsyslog/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
name:
- python3-dateutil
state: present
when: "'sysloghost' in group_names and ansible_distribution_major_version > '7'"
when: "'centrallog_servers' in group_names and ansible_distribution_major_version > '7'"
notify:
- "restart rsyslog"

Expand All @@ -23,7 +23,7 @@
enabled: true

- name: Forwarding journalctl to rsyslog forward syslog to central logserver
when: "'sysloghost' not in group_names"
when: "'centrallog_servers' not in group_names"
block:

# journald forwards logs to rsyslog
Expand Down Expand Up @@ -110,10 +110,12 @@

# central logserver

- name: Include tasks for central syslog server
ansible.builtin.include_tasks: rsyslog_central.yml
when: "'sysloghost' in group_names"
- name: Include tasks for configuring the central log server
when: "'centrallog_servers' in group_names"
block:
- name: Include tasks for central syslog server
ansible.builtin.include_tasks: rsyslog_central.yml

- name: Include tasks for authentication log processing
ansible.builtin.include_tasks: process_auth_logs.yml
when: "'auth_processor' in group_names"
- name: Include tasks for authentication log processing
ansible.builtin.include_tasks: process_auth_logs.yml
when: "'auth_processor' in group_names"
Loading